Back to Freecodecamp

Step 88

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

latest1.4 KB
Original Source

--description--

The equality operator can lead to some strange behavior in JavaScript. For example, "0" == 0 is true, even though one is a string and one is a number.

The <dfn>strict equality</dfn> operator === is used to check if two values are equal and share the same type. As a general rule, this is the equality operator you should always use. With the strict equality operator, "0" === 0 becomes false, because while they might have the same value of zero, they are not of the same type.

Update your done == count condition to use the strict equality operator.

--hints--

Your if condition should use strict equality.

js
assert.match(__helpers.removeJSComments(code), /while\s*\(\s*continueLoop\s*\)\s*\{\s*done\+\+;\s*if\s*\(\s*(?:done\s*===\s*count|count\s*===\s*done)\s*\)\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));
}*/

let continueLoop = false;
let done = 0;

while (continueLoop) {
  done++;
--fcc-editable-region--
  if (done == count) {

  }
--fcc-editable-region--
}

let result = ""

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

console.log(result);