Back to Freecodecamp

Step 74

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

latest972 B
Original Source

--description--

The pyramid looks a little funny now. Because you are starting the loop at 1 instead of 0, you do not need to add one to i when you pass it to padRow.

Update the first argument of your padRow call to be i.

--hints--

You should not pass i + 1 to padRow.

js
assert.notMatch(__helpers.removeJSComments(code), /padRow\(\s*i\s*\+\s*1/);

You should pass i to padRow.

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

--seed--

--seed-contents--

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

function padRow(rowNumber, rowCount) {
  return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber);
}

--fcc-editable-region--
for (let i = 1; i < count; i++) {
  rows.push(padRow(i + 1, count));
}
--fcc-editable-region--

let result = ""

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

console.log(result);