Learn Introductory JavaScript by Building a Pyramid Generator - Step 90

Tell us what’s happening:

I got the answer with a while loop but , It still shows as wrong asks me for a for loop. but When I do the for loop I still get it as 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));
}*/

let continueLoop = false;
let done = 1;

// User Editable Region

while(done <= count){
  rows.push(padRow(done,count))
  done++
}

// User Editable Region

  if (done === count) {
    continueLoop = false;
  } 


let result = ""

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

console.log(result);

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 90

What step are you doing? step 90 doesn’t ask for a for loop

these are the instructions

To make your pyramid generate again, push the result of calling padRow with done and count as the arguments to your rows array, similar to what you did in your first loop.

it asks for you to use push

1 Like

I am doing step 90. but I am on the right track by using while loop right?

you need to use the loop, but it’s already there, you need to add a thing inside the loop. In your code you changed the loop to be never-ending

Oh I need to edit the loop that I commented out with.

Hey thanks man, I figured it out

no, you need to reset the step and add a single line where indicated

1 Like