Learn Introductory JavaScript by Building a Pyramid Generator - Step 100

Tell us what’s happening:

Hello guys
Is that meant that I should use while(i>0){} in my for loop? Or above my for loop? Or after my for loop ?
Or non of them? Or instead I should change the element of my for loop to “i” be less than0?
Or I should apply other method ? I have tried all I mentioned above and no one was right!

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 (let i = count; false; false) {

}
while(i>0){}

// 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 100

The instructions do not say to add a while loop or any other kind of loop. Instead they say:

Set your loop’s condition to run when i is greater than 0 .

So this means you should change the loop condition (the one that checks if the loop should run or not).

Hi there!
The instructions is asking you to:
Set your loop’s condition to run when i is greater than 0.

Why you added while loop?

1 Like

hi there
tnx
i wrote that
for (let i > 0; false; false) {

but it wasnt correct

you are changing the first statement of the loop which is not the condition statement.
Please review loops here:

The first statement in the loop should be unchanged let i = count

1 Like