Learn Introductory JavaScript by Building a Pyramid Generator - Step 90

Tell us what’s happening:

Please can someone help me with this step cause i am confused.

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; i = false; i = 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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 90

Use let to declare your i variable, then, you do not need to re-assign i to the boolean. Just use the boolean without assigning it to any variable. Do this for both your condition and iteration statement.

2 Likes

Thanks it worked. I literally forgot about the “let”. Thanks a bunch.

You are very welcome.

1 Like

Please don’t post working solutions in the forum.
You can help your fellow students with hints so they can work the answer out themselves.