I have no idea what it wants me to do. What am I supposed to repeat and how exacly do I do that?
Your code so far
const character = "#";
const count = 8;
const rows = [];
// User Editable Region
function padRow(rowNumber, rowCount) {
return " "+ character.repeat(rowCount - rowNumber) + " ".repeat(rowCount - 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_7) 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 69
let’s look very closely at the code you have in order to answer your question.
This return has 3 parts separated by 2 plus signs. Let’s split them up to see them better. " "
+ character.repeat(rowCount - rowNumber)
+ " ".repeat(rowCount - rowNumber)
The first part is a single space
The second is the repeated character
The third is the repeated space (that is on the right-hand-side of the character).
Now that you see the three parts, refer back to what you need to do.
Repeat the first space as many times as you have repeated the other space.
Hopefully that is enough of a hint?
Edit: I just noticed that you changed the number of repeats you are doing on the middle character variable. Please don’t do that. Return it back to the original amount. (click reset to see what that was)
It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.
We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.