I am calling the repeat method and I’ve tried various ways like: return character.repeat(8 - ) + " ". I don’t know how to call the repeat method on my " " strings using the rowCount and rowNumber.
Your code so far
const character = "#";
const count = 8;
const rows = [];
// User Editable Region
function padRow(rowNumber, rowCount) {
return character.repeat(8 - []) + " ";
}
// 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/128.0.0.0 Safari/537.36
Challenge Information:
Learn Introductory JavaScript by Building a Pyramid Generator - Step 69
the original code for this step shows this: return " " + character.repeat(rowNumber) + " ";
notice that .repeat function call? It is added to the immediate right of the variable character.
This is done to make character repeat a certain number of times.
So to make the space character repeat, add the .repeat with the parenthesis and the value that it repeats to the immediate right of the " " space character.
You should not have deleted any code. Reset the step to restore the code and this time only add the repeat calls. You will need two of them. (One for each space character)
This is me adding code without deleting any, and I’m still not getting it to pass.
function padRow(rowNumber, rowCount) {
return " ".repeat(rowCount - rowNumber) + character.repeat(rowNumber) + " ";
}