Learn Introductory JavaScript by Building a Pyramid Generator - Step 45

Tell us what’s happening:

I don’t really understand why my code is wrong because I think it is correct. please help and correct me if I’m wrong. step 45

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);

Your browser information:

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

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 45

what do you think this line is doing?

repeating the value of character

and then what happens to the repeated value?

It is repeated the number of (i) which is 8

ok, but after that? does it go in the array? or not?

To be honest I don’t know anymore because I googled it and that’s what I got.

PLEASE HELP​:sob::pray: I REALLY DON’T KNOW WHAT TO DO ANYMORE

Welcome to the forum @nompumelelondlovu418

You should use the .repeat() method in the .push() method

You have two lines of code in the for loop.
Try to combine them into one line.

This way the repeated character is "pushed" into the rows array.

Happy coding

:sob::sob::sob: can someone please help me I’ve been stuck on step 45 since last night PLEASE fix my code I don’t know how many times I’ve changed it.
for (let i = 0; i < count; i = i + 1) {
character.repeat(i);
let row = character.repeat(i);
rows.push(row);
}

you aren’t using character.repeat(i) in the .push() method. You have created a row variable and assigned the value character.repeat(i) to it. Then you used the row variable in the .push() method.

You need to strictly follow the instructions.

this does what is asked, but you need to not create the row variable and make them a single line

I got it thank you for your help🙏