Learn Introductory JavaScript by Building a Pyramid Generator - Step 99

Tell us what’s happening:

Hello friends
I’ll be greatful if you help me with step 99

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

let i = count;

// 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 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Mobile Safari/537.36

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 99

you have not created the for loop, that was one of the pieces of the for loop, it’s not accepted alone

1 Like

For(let I= count, I=false )like this?

Look at the other for loop commented out in your code for an example of the syntax.

This is how the different parts of the loop are named:

for (<declare iterator>; <condition>; <iteration>) {

}
2 Likes

@pkdvalis why does it say your code should have a for loop even when I have used it?

hi @Maham , please open your own topic

If you have a question about a specific challenge as it relates to your written code for that challenge and need some help, click the Help button located on the challenge. This button only appears if you have tried to submit an answer at least three times.

The Help button will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Thank you.