Learn Introductory JavaScript by Building a Pyramid Generator - Step 69

Tell us what’s happening:

I have no idea what it wants me to do. What am I supposed to repeat and how exacly do I do that?

Your code so far

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


// User Editable Region

function padRow(rowNumber, rowCount) {
  return " "+ character.repeat(rowCount - rowNumber) + " ".repeat(rowCount - 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 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 69

You’ve done it correctly in terms of repeating the space on the right of the character but you haven’t done it to the space character on the left.

Edit: also do not change the repetition on the character variable. That was not supposed to be changed in this step. You can reset and try again.

you gotta show me where because it is kinda hard to understand where the space is supposed to be.

there are 2 space characters here. One on the left of the repeated character and one on the right. You’ve not repeated the one on the left yet.

As of right now I have this:
return " " + character.repeat(rowNumber) + " ".repeat(rowCount - rowNumber);
But i need help with centering it.

how do i do that because everything I try turnes out to be a synthex error.

let’s look very closely at the code you have in order to answer your question.

This return has 3 parts separated by 2 plus signs. Let’s split them up to see them better.
" "
+
character.repeat(rowCount - rowNumber)
+
" ".repeat(rowCount - rowNumber)

The first part is a single space
The second is the repeated character
The third is the repeated space (that is on the right-hand-side of the character).

Now that you see the three parts, refer back to what you need to do.
Repeat the first space as many times as you have repeated the other space.

Hopefully that is enough of a hint?

Edit: I just noticed that you changed the number of repeats you are doing on the middle character variable. Please don’t do that. Return it back to the original amount. (click reset to see what that was)

I want to thank you for taking your own time and helping me.

1 Like

Buenas a todos;
Mi respuesta y solución ya probada es la siguiente:
function padRow(rowNumber, rowCount) {
Mod edit: code removed
}

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.