Learn Introductory JavaScript by Building a Pyramid Generator - Step 65

Tell us what’s happening:

Im stuck on functions. The question wants me to return the result of the .REPEAT() method. My code seems to be correct but i still get the error message. Please help

Your code so far

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


// User Editable Region

function repeatCharacter(rowNumber, rowCount) {

}

// User Editable Region



for (let i = 0; i < count; i = i + 1) {
  rows.push(character.repeat(i + 1))
}

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 OPR/116.0.0.0

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 65

You renamed the function and didn’t put anything inside the code block

Renaming the function might fail your test along with not adding any code to where you supposed to.

Can you provide the code you used:

function repeatCharacter(character, rowNumber) {
return character.repeat(rowNumber)
}

Even if the rest of the code is wrong please don’t post your solutions.

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. How to Help Someone with Their Code Using the Socratic Method

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.

Sorry for that but thats the problem. My solution seems to be correct and yet i get an error message whenever i check the code and move on to the next question.

Im trying to find out what im doing wrong. The error message is always “return the result of .repeat() method”.

These questions might be helpful:

Why did you rename the function instead of leaving the original name?
Also, why did you change the function parameters? You already have character declared earlier in your code but when you add character as a perameter to your function now your using what gets inputted to the function when you call that function instead the challege you already declared.

One easy way might be to reset the challege and re-enter the code in the code block. The code inside the function is good but the rest is not.

it made sense that i do that. I shouldn’t change the function and the parameters?

Use the return keyword to return the value of the character variable, repeated rowNumber times.

Why would does it make sense to change the function name and the parameters when that is not in the instructions?

I recommend playing with the code, so you can do whatever you wnat.

fair point.

im still confused though. Could you give me an example of what i should do?

I mentioned it in an earlier post here on this board.

Did you have any question about anything in the code that is giving you trouble?

I wasnt paying attention to the fact that i already declared the character variable. I solved it, thanks for heads up

1 Like