Update your blank space strings to be repeated – rowCount - rowNumber – times. I think this is confusing
Your code so far
const character = "#";
const count = 8;
const rows = [];
// User Editable Region
function padRow(rowNumber, rowCount) {
return "character.repeat(rowCount - rowNumber)" + character.repeat(rowNumber) + " character.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 + 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/131.0.0.0 Safari/537.36
Challenge Information:
Learn Introductory JavaScript by Building a Pyramid Generator - Step 69
It looks like you’re getting confused by using a literal string to represent a space. Your updated code would repeat the word “character” rather than a space. You can test by looking at what your code is returning in the console.
I don’t understand, I already changed the string to “.repeat()” but it doesn’t happen
Your code so far
const character = "#";
const count = 8;
const rows = [];
// User Editable Region
function padRow(rowNumber, rowCount) {
return character.repeat(rowCount - rowNumber) + character.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 + 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/134.0.0.0 Safari/537.36
Challenge Information:
Learn Introductory JavaScript by Building a Pyramid Generator - Step 69
See where in the previous step you concatenated empty strings to the beginning and end of character.repeat(rowNumber)?
Now all you need to do is follow that same syntax to repeat those empty strings, but this time you would pass rowCount - rowNumber to the repeat() method rather than rowNumber.
Also, you might be more comfortable with the Full Stack Developer curriculum. There are a lot of short video explanations with 3-question quizzes to test grasp of the information. In addition, there are labs, workshops, a review and a final quiz for each topic.