I need to concatenate an empty space → " " before and after my character string. I am not entirely sure how to even do that. I don’t want an answer, I need to know what I am missing in context of how I figure out its placement.
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 (Macintosh; Intel Mac OS X 10.15; rv:125.0) Gecko/20100101 Firefox/125.0
Challenge Information:
Learn Introductory JavaScript by Building a Pyramid Generator - Step 61
you can’t have the + operator after the return. Removing that you have
here you have concatenated a space before the character string, so you are halfway there, you need to add a + after, and concatenate an other " " space string
Thank you for your response. I interpreted it as that I should remove the word return and so I did that and finally I broke down and asked Ai for the solution and why it was the solution and so I had it right the very first time I did it – sorta… the first thing i tried was
return + " " + character.repeat(rowNumber) + " ";
It really tore me up when the ai told me the solution. I kept saying “I did that! I did that!” and then I looked back here and seen what I did wrong and I was really really close to the right answer but I didn’t know that I only needed the whitespaces only around the repeated character string lol