Learn Introductory JavaScript by Building a Pyramid Generator - Step 90

Tell us what’s happening:

What does a paragraph : " Start by creating a new for loop. Declare your iterator i and assign it the value of count, then use the boolean false for your condition and iteration statements." meaning ?

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;i>0;i--){padRow(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 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 90

Hello!
So this is your condition and iteration statements 1>0 and i-- which you should set to false

hey there!
You for...loop body {} should be empty.
The instructions is asking you, to declare the i as iterator and assign the variable count to i as your for loop iterator. And for condition and iteration, use the boolean false.
You need to simply follow the instructions as it is.
@chung_son

Okay … I thought so far … it’s simple doing step by step … thanks a lot !

1 Like

Your welcome, keep it up. Happy Coding.