Learn Introductory JavaScript by Building a Pyramid Generator - Step 65

Tell us what’s happening:

Step 65
Remember in an earlier step, you learned about return values. A function can return a value for your application to consume separately.

In a function, the return keyword is used to specify a return value. For example, this function would return the value given to the first parameter:

Example Code
function name(parameter) {
return parameter;
}
Use the return keyword to return the value of the character variable, repeated rowNumber times.

Does anyone know what they are here for?

Your code so far

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


// User Editable Region

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

// 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 + "\n" + row;
}

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/126.0.0.0 Safari/537.36

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 65

Hi there!

You need to add one linear return statement. Instructions is asking you to return .repeat() method on character variable with rowNumber times.
Currently you have repeat method on rowNumber and character as times. Then you are returning the character variable separately.

3 Likes