Learn Introductory JavaScript by building a pyramid. Step 58

I am stuck on this step. The error message says I need to return the result of my .repeat() call. This is what I tried .

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

The instructions seem to suggest this is correct, and I have tried anything I can think of after the return keyword. I am sure I am missing something obvious. Can someone give me a gentle nudge?

Hello, I think you need to combine the two lines to one.

Sadly I do not think that is going to fix it.

Ok can you post the link to the challenge?

Maybe I worded it wrong character.repeat(rowNumber); return rowNumber;
should be one line of code. Good luck

.repeat() returns a new string, that is what you should be returning out of the function.

function nom(times) {
  return "nom".repeat(times)
}

console.log(nom(3)) // "nomnomnom"

ohhh. sorry i think i misunderstood. thank you so much

1 Like

hmmmmm, i guess i dont understand. I am trying to combine the two lines even though the instructions say otherwise. still not working. thanks anyway

Try to follow @losjorgs example replaceing the code with yours.

I have tried that and still get the same error.

Post your new code.

When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

ok… i think i am just going to find a new project to work on. I am doing exactly as people suggest and exactly as the step suggests and getting no where. thanks anyway.

Why the reluctance to show your new code? It’s really the easiest way to help you and it’s really hard to help on any other projects if you don’t share code as you work on fixing

Please post your code, we can not help you without seeing your code.


rowNumber is a variable containing a number.

character is a variable containing a string.

.repeat() is a string method, it accepts a number as the argument for how many times it should repeat the string. It returns a new string.

You call .repeat() on the string assigned to the character variable, passing rowNumber as the argument to .repeat() specifying how many times the string should be repeated. It returns a new string, and that new string is what you return out of the function.