Learn Introductory JavaScript by Building a Pyramid Generator - Step 90

Tell us what’s happening:

please help me with this code , how to add Boolean to for loop

Your code so far

for (i=count;i<count;false;i++){

}

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

}

// 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 (Windows NT 10.0; Win64; x64) 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

Declare your iterator i and assign it the value of count , then use the boolean false for your condition and iteration statements.

(iterator=value, condition, iteration)

2 Likes

for (i=count;i<count;i=false) {

}

still stuck

Your first section is ok, now just put it the required boolean for the last two sections.

1 Like

follow the instruction as it is . use false for your for...loop condition and itirataion.

1 Like

for(let i=count; i=false;)(i++);false; {

}
doesn’t working

That is not the correct syntax, and your condition is also not correct.

The example loop given in the commented out code:

for (let i = 1; i <= count; i++) {
  rows.push(padRow(i, count));
}

The loop you are asked to write should use count for the i initialization, and it should use false instead of i <= count and i++. The loop body should be empty.

1 Like

Thank you so much it worked!

Sorry for the late response. Glad you figured it out. :+1:

@ashwinikul80