I seem to have done everything correctly but my code does not pass. I could be wrong so can anyone help me find out where i went wrong?
Your code so far
const character = "#";
const count = 8;
const rows = [];
function padRow(rowNumber, rowCount) {
return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber);
}
// TODO: use a different type of loop
/*for (let i = 1; i <= count; i++) {
rows.push(padRow(i, count));
}*/
/*while (rows.length < count) {
rows.push(padRow(rows.length + 1, count));
}*/
// User Editable Region
for (let i = count; i > 0; i--) {
rows.push(padRow(i, count));
}
// User Editable Region
let result = ""
for (const row of rows) {
result = result + row + "\n";
}
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/132.0.0.0 Safari/537.36 OPR/117.0.0.0
Challenge Information:
Learn Introductory JavaScript by Building a Pyramid Generator - Step 100
Please provide the code of what you did so we can better help.
When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.
Set your loop’s condition to run when i is greater than 0 .
for (initialization; condition; increment/decrement) {
// Code to be executed in each iteration
}
No you did not do that. Above is the syntax for a for loop. You changed the condition and the increcrement/decrement
What are the instructions asking you to do?
What parts did you change?
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.