Learn Introductory JavaScript by Building a Pyramid Generator - Step 45

Tell us what’s happening:

Use the .repeat() method on your character, and give it i for the number.

Your code so far

const character = "#";

// User Editable Region

const count = 8;
const rows = [];

for (let i = 0; i < count; i = i + 1) 

character.repeat(i);


let result = ""

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

console.log(result);

// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 Edg/119.0.0.0

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 45

Hi,
you need to reset your code because originally there is rows.push(character) inside your for loop. The step wants you to use .repeat() on the character inside the .push().
Good luck!

hi @JuniorQ Its still not working out and im stuck

Can you share your updated code please?

for (let i = 0; i < count; i = i + 1) {

rows.push(character);

}

@JuniorQ This is it after resetting the code

and what should you do with this code?

Im asked to use the .repeat() method in the .push() method

try to write that please

You should now use the .repeat() method on the character as the instructions point out.
Good luck!

Finally it worked. thanks @JuniorQ @ILM

1 Like

Hey man,how did you solve the problem because im also stuck??

Hey there,
you can create a new topic using the help button on the step you’re stuck in. The help button appears after you’ve tried submitting your code at least three times.
Good luck!

it’s not working rows.push(character);
character.repeat(i);
}

Hi there and welcome. Create your own topic to the challenge step using Help button. It’s appear below the challenge editor, when you try to submit wrong code more than three times.

ok thanks a lot i have tried that and it worked
!!!