Learn Introductory JavaScript by Building a Pyramid Generator - Step 64

Hello! Anyone help with this step…Thank you…what should I do?

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



function padRow(rowNumber, rowCount) {
  return repeat(rowCount - rowNumber) + character.repeat(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);

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.

Hey @JeremyLT , The challenge is not yet solved…

1 Like

Which is why I didn’t make that reply to you but to the poster who wrote the solution code :wink:

Haha ok But I don’t see any solution code…

.repeat() is a string method - you need to call it on some string, as myString.repeat()

1 Like

@JeremyLT , Sorry, but I’m having trouble understanding your explanation. Here’s what I tried to do, but it’s still not working.

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

You aren’t calling .repeat() as a method on a string. What string are you supposed to repeat?

1 Like

Hello. The correct answer is:

Mod Edit: SOLUTION 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.

actually ,i am stuck on same step ,i need some help,how did u solve?

If you have a question about a specific challenge as it relates to your written code for that challenge and need some help, click the Ask for Help button located on the challenge (it looks like a question mark). This button only appears if you have tried to submit an answer at least three times.

The Ask for Help button will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Thank you.

hey @balatamna16, I figured it out, so they want us to… Update the blank space strings to be repeated rowCount - rowNumber times. so all you have to do is to add the repeat() next to both the blank space strings.

Use the .repeat() method with rowCount minus rowNumber as parameter, in your empty strings
hope I helped you!