Learn Introductory JavaScript by Building a Pyramid Generator - Step 99

Tell us what’s happening:

Hi, I used i in the iterator assigned with the value of count. Then I used false in the condition and iteration statements. I am not sure what is wrong.

Your code so far

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));
}*/

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


// User Editable Region

for (i = count, false, false){}

// User Editable Region


let result = ""

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

console.log(result);

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.6 Safari/605.1.15

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 99

Hi there. We use a semi-colon ; to separate the different parts of a loop expression.

hi! after fixing the mistake, I’m receiving an error in the output that says “cannot find variable i”. What does this mean?

It means you didn’t define i. And didn’t actually definite it. Sure you assigned i a value but the runtime doesn’t know what i is.

ah I see. thank you!!!