Back to Freecodecamp

Step 44

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

latest866 B
Original Source

--description--

Printing numbers won't result in a visually appealing pyramid. Now that you're outputting the formatted content of your rows array, it's time to update your original loop.

Instead of pushing i to the array, push the value of your character variable.

--hints--

You should no longer push your i variable.

js
assert.notMatch(__helpers.removeJSComments(code), /rows\.push\(\s*i\s*\)/);

You should push your character variable.

js
assert.match(__helpers.removeJSComments(code), /rows\.push\(\s*character\s*\)/);

--seed--

--seed-contents--

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

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

let result = ""

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

console.log(result);