Back to Freecodecamp

Step 97

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

latest1023 B
Original Source

--description--

Now you no longer need your done variable. Remove the increment operation from your loop, and the variable declaration for done.

--hints--

You should not increment the done variable.

js
assert.notMatch(__helpers.removeJSComments(code), /done\+\+/);

You should no longer have a done variable.

js
assert.notMatch(__helpers.removeJSComments(code), /done/);

--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);
}

// TODO: use a different type of loop
/*for (let i = 1; i <= count; i++) {
  rows.push(padRow(i, count));
}*/

--fcc-editable-region--
let done = 0;

while (rows.length < count) {
  done++;
  rows.push(padRow(rows.length + 1, count));
}
--fcc-editable-region--

let result = ""

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

console.log(result);