Tell us what’s happening:
I’m stuck on step 100 of the learn-introductory-javascript-by-building-a-pyramid-generator where I’m asked to set the loops condition to run where i is greater than 0. I need help please.
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--) {
}
// User Editable Region
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/127.0.0.0 Safari/537.36
Challenge Information:
Learn Introductory JavaScript by Building a Pyramid Generator - Step 100
1 Like
You did an extra step. Only fill in the condition, don’t do the iteration yet the last section.
1 Like
Thanks for the reply but please can you explain better? Thanks again
1 Like
for (let i = count; false; false) {
}
There’s two false
here. Just replace the 1st one, leave the second one as false
Set your loop’s condition to run when i
is greater than 0
.
Follow the instructions exactly, they don’t mention anything except run when i
is greater than 0
. It doesn’t mention how i
should change at all
2 Likes
Now it’s saying I is not defined
1 Like
Thank you very much for you kind help
2 Likes
Please show your updated code
1 Like
for(i = count; i = i > 0; false) {
}
1 Like
Compare this to the first code you posted.
You can also see another example of a for loop further up in your code.
1 Like
I know I’m probably getting on your nerves and I’m sorry about that. But this step has me stressing for over an hour now. I’ve compared and done everything but it doesn’t seem to work.
3 Likes
You had it right the first time. You just also filled in the 2nd false
which is the next step, so you were a step ahead.
2 Likes