Learn Introductory JavaScript by Building a Pyramid Generator - Step 63

Tell us what’s happening:

How can l use the addition operator to concatenate a blank space " " to the beginning and end of my repeated character string?

Your code so far

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


// User Editable Region

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

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

console.log(result);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:126.0) Gecko/20100101 Firefox/126.0

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 63

This is the line of code before you edit it:

return character.repeat(rowNumber);

All you should be doing is adding a single space to the beginning and end, using the addition operator.

You’ve added "character" (twice), which is not required. Also, you can’t have ; symbols in the middle of a return value like this, so remove those too:

return " " + "character"; character.repeat(rowNumber); " " + "character";

thank you, it has passed

1 Like