hello guys!
how i can You concatenate a single space to the beginning of the returned value?
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 (X11; Linux x86_64) 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 68
We just need to add an empty space at the beginning and the end of the returned string, there are no quotation marks here.
For example:
When character.repeat(rowNumber) is "AAA", the current function padRow returns the string "AAA".
What we need to do is: We need to make changes to the padRow function to make it returns the string " AAA " (with the space at the begining and the end), instead of "AAA".
About the quotation marks (""), it’s the sign to let us know that the data we are dealing with is a string.
For example, Hello! is not a string, but "Hello!" is a string.