Back to Freecodecamp

Step 85

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

latest1.1 KB
Original Source

--description--

A <dfn>while</dfn> loop will run over and over again until the condition specified is no longer true. It has the following syntax:

js
while (condition) {
  logic;
}

Use that syntax to declare a while loop with continueLoop as the condition. The body should be empty.

--hints--

You should use a while loop.

js
assert.match(__helpers.removeJSComments(code), /while/);

Your while loop should use continueLoop as the condition.

js
assert.match(__helpers.removeJSComments(code), /while\s*\(\s*continueLoop\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);
}

// 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;

--fcc-editable-region--

let result = ""

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

console.log(result);