Back to Freecodecamp

Step 113

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

latest1.2 KB
Original Source

--description--

Use an if statement to check if inverted is true. Remember that you do not need to use an equality operator here.

--hints--

You should use an if statement.

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

Your if statement should check if inverted is true.

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

Your if condition should not use any comparison operators.

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

--seed--

--seed-contents--

js
const character = "#";
const count = 8;
const rows = [];
let inverted = true;

function padRow(rowNumber, rowCount) {
  return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber);
}

// TODO: use a different type of loop
--fcc-editable-region--
for (let i = 1; i <= count; i++) {

  rows.unshift(padRow(i, count));
}
--fcc-editable-region--

/*while (rows.length < count) {
  rows.push(padRow(rows.length + 1, count));
}*/

/*for (let i = count; i > 0; i--) {
  rows.push(padRow(i, count));
}*/

let result = ""

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

console.log(result);