Back to Freecodecamp

Step 93

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

latest1.0 KB
Original Source

--description--

Your loop is no longer relying on the continueLoop variable. This makes the variable an <dfn>unused declaration</dfn>. Generally, you want to avoid unused declarations to prevent future confusion.

Remove your continueLoop variable.

--hints--

You should no longer have a continueLoop variable.

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

--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 continueLoop = false;
let done = 0;

while (done !== count) {
  done++;
  rows.push(padRow(done, count));
}
--fcc-editable-region--

let result = ""

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

console.log(result);