Learn Introductory JavaScript by Building a Pyramid Generator - Step 61

Tell us what’s happening:

where in the code do we concatenate an empty space before and after the return value of the repeated character?

Your code so far

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


// User Editable Region

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

// 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) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36 Edg/124.0.0.0

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 61

Hello, this will be the equivalent of wrapping the code you already have. Im assuming this was your solution but thats not what there asking. const character = “#”;
const count = 8;
const rows = ;

// User Editable Region

function padRow(rowNumber, rowCount) {
repeatedCharacter = “” + “#” + “”;
return character.repeat(rowNumber);
}

// 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); hint: ‘’ " + code + " "

concatenate your return value using addition operator and add empty space before and after it, using strings " "

Thank you for the quick feedback, unfortunately, I am yet not discreetly clear of where exactly to concatenate. Do I call the function to console.log, then concatenate empty spaces before and after the return code in the function?

Your target for this challenge is existing return character.repeat(rowNumber).
You need to to concatenate your return value using addition operator and add space before and after it using strings. Reset your challenge and try again.
@Abycode

Thank you for your insight

Thank you for your help

1 Like