Learn Introductory JavaScript by Building a Pyramid Generator - Step 99

Tell us what’s happening:

hi i followed this format: for(iterator,conditon,iteration) is this correct?

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; i--;) {
    rows.push(padRow(i, count));

}

// User Editable Region


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 99

Yes, this format is ok but your implementation is incorrect. Both the condition and iteration should take the boolean false

1 Like

why is i-- not relevant?

Because the instructions require you to use a different iteration.

2 Likes

so how does it decrement if i-- is not used but instead using the boolean “false”?

Those features will be implemented in the next steps, I guess these were used as placeholders.

2 Likes

ah you’re right because i’ve progressed onto the next steps and they’ve used i=i-1 as decrementing, thank you for your help :))

2 Likes