Learn Introductory JavaScript by Building a Pyramid Generator - Step 99

Tell us what’s happening:

I don’t know what is wrong with the code. It says : Your for loop should initialise i with the value of count. I have initialized i to count. What is wrong here? I removed the var and checked, that doesn’t work either.

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 (var 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 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 99

It is solved now. I had to update let instead of var

2 Likes

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.