Tell us what’s happening:
I am unable to return the value of .repeat() method.Please help to figure out this
Your code so far
const character = "#";
const count = 8;
const rows = [];
// User Editable Region
function padRow(rowNumber, rowCount) {
return character(rowNumber.repeat);
character.repeat(rowNumber);
return;
}
// 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/132.0.0.0 Safari/537.36
Challenge Information:
Learn Introductory JavaScript by Building a Pyramid Generator - Step 65
function padRow(rowNumber, rowCount) {
return character(rowNumber.repeat); ← this isn’t right . character isn’t a function
character.repeat(rowNumber); ← this is right but you’re not returning it
return;
so in function should i use padRow because that is function
This is what you’re asked to do.
Use the return
keyword to return the value of the character
variable, repeated rowNumber
times.
Inside padRow you wrote character.repeat(rowNumber)
but you have to return it.
function padRow(rowNumber, rowCount) {
// Here you return what you wrote
}
yes I am stuck at return .repeat() method
should I use return character or console.logPadRow
Inside the function definition, you just need to return the character
variable repeating rowNumber
times.
Write a one line return statement using return
keyword before the above value. Remove other extra lines of code from inside of function definition.