Back to Freecodecamp

Step 64

curriculum/challenges/english/blocks/learn-introductory-javascript-by-building-a-pyramid-generator/660f2eccfe3f820304af1b39.md

latest1.2 KB
Original Source

--description--

In order to know how to format a row, your padRow function will need to know which row number you are on, and how many rows in total are being generated.

The best way to do this is by creating function parameters for them. Give your padRow function a rowNumber and rowCount parameter. Multiple parameters are separated by a comma:

js
function name(first, second) {

}

--hints--

Your padRow function should have a rowNumber parameter.

js
assert.match(__helpers.removeJSComments(code), /function\s+padRow\s*\(\s*rowNumber/);

You should add a comma after your rowNumber parameter.

js
assert.match(__helpers.removeJSComments(code), /function\s+padRow\s*\(\s*rowNumber\s*,\s*/);

Your padRow function should have a rowCount parameter.

js
assert.match(__helpers.removeJSComments(code), /function\s+padRow\s*\(\s*rowNumber\s*,\s*rowCount\s*\)/);

--seed--

--seed-contents--

js
const character = "#";
const count = 8;
const rows = [];

--fcc-editable-region--
function padRow() {

}
--fcc-editable-region--


for (let i = 0; i < count; i = i + 1) {
  rows.push(character.repeat(i + 1))
}

let result = ""

for (const row of rows) {
  result = result + row + "\n";
}

console.log(result);