Learn Introductory JavaScript by Building a Pyramid Generator - Step 94

Tell us what’s happening:

I don’t understand why my code is not passing, can someone help?

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 = i -= 1) {
  rows.push(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 94

It looks like the syntax is not quite right.
I would reset the lesson.

I would suggest look at the docs here to get the correct syntax for using this operator

This article also has good example to help you fix your syntax

but basically your issue is here

that is the part that is not the correct use of syntax.

so review, those examples and that should help you better understand correct syntax

hope that helps

2 Likes

That worked! Thankssssss

why wouldnt you just give the answrer smh

because copying code is not learning

If you have a question about a specific challenge as it relates to your written code for that challenge and need some help, click the Ask for Help button located on the challenge (it looks like a question mark). This button only appears if you have tried to submit an answer at least three times.

The Ask for Help button will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Thank you.

1 Like

Leyendo estas respuestas muy complicadas me he liado, solo te pide false para condicion y false para iteracion.