Learn Introductory JavaScript by Building a Pyramid Generator - Step 63

Tell us what’s happening:

i need spaces infront and behind each row that contains a # but using several different methods i have not been able to any help on this matter is greatly appreciated

Your code so far

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


// User Editable Region

function padRow(rowNumber, rowCount) {
  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; rv:126.0) Gecko/20100101 Firefox/126.0

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 63

Hi, welcome to the forum! :wave:

Use the addition operator to concatenate a blank space " " to the beginning and end of your repeated character string.

What did you try? I don’t really see an addition operator + or space " " anywhere.

i added return statements return " " + " " before and after the “return character.repeat(rowNumber);” statement i also tried adding the spaces inside the bracket “return character.repeat(” " + rowNumber + " ");

in, const character=“#” add space to make it
const=" “+”#“+” "
i hope it will do it

this solves the problem but i didnt feel like that was the intended solution so i was hoping someone knew how it is actually solved not sure though

The first approach is correct, can you show me that code?

When you repeat it, you would get:

 #  #  #  #  # 

Spaces between every pound, which is not correct. That’s the character string, but not the repeated character string (where the repeat method is used)

i found the solution with the help of a friend thanks for all the input!

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