Learn Introductory JavaScript by Building a Pyramid Generator - Step 69

Tell us what’s happening:

Step 69 test questions:

Update your blank space strings to be repeated – rowCount - rowNumber – times. I think this is confusing :face_with_spiral_eyes:

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

you don’t have space strings anymore now

like you did with character, you can use methods directly on literal strings

"hi".repeat(3); // hihihi

return “character”.repeat(rowCount - rowNumber) + character.repeat(rowNumber) + “character”.repeat(rowCount - rowNumber); :thinking:

where are the space strings? can you use your own words to expalin your doubts please?

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.

1 Like

can someone help me ? :expressionless_face:

Hi @rhizna39

Please post your full updated code, and questions so the forum can assist.

Happy coding

Tell us what’s happening:

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

Hi @rhizna39

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

The .repeat() method needs to go on the " " strings.
Please reset the step to restore the original code and try again.

Happy coding

How do you think you could represent a string with a space in it?

UPDATE: Let’s get you past this.

Please RESET this step in the challenge so you start with the given code again. When you’re done, you should see this:

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

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.

Is it like this ?
return character.repeat(“rowNumber-rowCount”) + character.repeat(rowNumber) + character.repeat(“rowNumber-rowCount”);

Btw i’m sorry for the slow response, I have something to do

you still do not have the " " strings

You created another post for the same step instead of responding to this one:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 69 - JavaScript - The freeCodeCamp Forum

sorry about that :sweat_smile:

string where ? it doesn’t show the code in question

exactly, you have deleted that. Reset the step, it will appear back