Learn Introductory JavaScript by Building a Pyramid Generator - Step 99

Tell us what’s happening:

I need Help with the for loop in this code. Instructions want me to create an inverted pyramid structure by assigning i to count. I’m hung up on using the loop condition to be a false value. typing i = false does not seem to do anything. I’ve tried using falsy values like 0 and it doesn’t work either. I’m not sure what to do at this point.

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 = false;) {

}

// 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 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 99

write just false, without i =

1 Like

That was it. Thank you so much.