Learn Introductory JavaScript by Building a Pyramid Generator - Step 45

Tell us what’s happening:

Any help would be appreciated. I don’t know what I’m doing wrong I tried every thing I can think of but I still can’t solve it. it says that I need to use the .repeat( ) method in the .push( ) method and I don’t know what to do I tried using commas, semicolons and nothing seems to work.

Your code so far

const character = "#";
const count = 8;
const rows = [];


// User Editable Region

for (let i = 0; i < count; i = i + 1) {
  rows.push(character); 
  character.repeat(i);
}

// User Editable Region


let result = ""

for (const row of rows) {
  result = result + row + "\n";
}

console.log(result);

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 45

you need to change this line
you need to change what is pushed to rows

1 Like

I want to thank you for taking the time to answer my question. I am sorry but I don’t fully understand what your getting at. And so you don’t get me wrong I don’t want you to answer me the question I just want to understand then solve.

Use the .repeat() method on your character

You’ve added a new line:

  character.repeat(i);

but you need to use the repeat method on the character variable in this line:

  rows.push(character); 
1 Like

Thank you so much for helping me.

1 Like