Back to Freecodecamp

Step 84

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

latest1.8 KB
Original Source

--description--

Now that you have practiced working with if...else if...else statements, you can remove them from your code.

Once you complete that, use let to declare a continueLoop variable and assign it the boolean false. Then use let to declare a done variable and assign it the value 0.

--hints--

You should not have an if statement.

js
assert.notMatch(__helpers.removeJSComments(code), /if\s*\(/);

You should not have an else if statement.

js
assert.notMatch(__helpers.removeJSComments(code), /else\s+if\s*\(/);

You should not have an else statement.

js
assert.notMatch(__helpers.removeJSComments(code), /else\s*\{/);

You should use let to declare a continueLoop variable.

js
assert.match(__helpers.removeJSComments(code), /let\s+continueLoop/);

Your continueLoop variable should have the value false.

js
assert.isFalse(continueLoop);

You should use let to declare a done variable.

js
assert.match(__helpers.removeJSComments(code), /let\s+done/);

Your done variable should have the value 0.

js
assert.strictEqual(done, 0);

--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--
if ("") {
  console.log("Condition is true");
} else if (5 < 10) {
  console.log("5 is less than 10");
} else {
  console.log("This is the else block");
}
--fcc-editable-region--

let result = ""

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

console.log(result);