Learn Introductory JavaScript by Building a Pyramid Generator - Step 69

Tell us what’s happening:

I have a big difficult here. Can someone help me with this exercise ?

Your code so far

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


// User Editable Region

function padRow(rowNumber, rowCount) {
  return " " + character.repeat(rowNumber) + " ";
}

// User Editable Region


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

let result = ""

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

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/128.0.0.0 Safari/537.36

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 69

what issue are you having?

Please Tell us what’s happening in your own words.

Learning to describe problems is hard, but it is an important part of learning how to code.

Also, the more you say, the more we can help!

Hi @Oliveira

  1. You should call .repeat() on your " " strings to repeat them rowCount - rowNumber times.

For this challaenge add the .repeat() method to the strings.

Happy coding

a tried this code:
return rowNumber.repeat(" “) + character.repeat(rowNumber) + rowCount.repeat(” ");

Hi there,

The character that repeats goes on the left of the .repeat call

A number or a variable whose value is a number goes inside the repeat parenthesis.

2 Likes

i tried add the method, but I don’t know how to use the value.

Hi @Oliveira

Use the following as a guide.

If you are still stuck please post your full code.

Happy coding

I’ve been tried code similar like this:
return character.repeat(rowCount - rowNumber) + character.repeat(rowNumber) + character.repeat(rowCount - rowNumber);

i finnily found de solution bro, thank u for help me.

1 Like

This was the answer that helped me! Thank you!!

1 Like

this is the hint that did it for me too!

1 Like