Learn Introductory JavaScript by Building a Pyramid Generator - Step 82

Tell us what’s happening:

Required is to change the while loop condition to check if done and count are not equal. The condition was: done++; I added the inequality of done and count, but this is not recognized. The test result continued to say that the while condition should be changed to check if done and count are not equal.
So far, the code is:
while (continueLoop) {
done++, done !== count;
rows.push(padRow(done, count));
continueLoop = false;

I don’t know what is wrong in the condition as I put it.

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));
}*/

let continueLoop = false;
let done = 0;


// User Editable Region

while (continueLoop) {
  done++, done !== count;
  rows.push(padRow(done, count));
  continueLoop = false;
}

// 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/125.0.0.0 Safari/537.36 Edg/125.0.0.0

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 82

HI @haahinnawy !

While this is the correct way to check if done is not equal to count

you wrote it in the wrong place.

reset the lesson

The lesson says to update your while loop condition

that is this part

hope that helps

2 Likes

Thank you. I reset the lesson as you said but the test comment is still the same. Considering what you said about a wrong place I tried to write the two elements of the condition in two separate lines but this was also invalid. I can’t see other alternatives for places.

Hey @haahinnawy !
Please Post your updated code here.

Hello!
I think this step would like us to change the condition in the () here using the !== to check if done is not equal to count.

I hope this helps you.

Yes, I tried this. The code now is:
while (continueLoop, done++, done !==count) {
rows.push(padRow(done, count));
}
Yet, the test result is the same.

ok, no, only the condition goes in here, that was first continueLoop but you want to replace it.Delete continueLoop, move done++ in the loop body

Also do not use the comma operator everywhere

1 Like

You need to update only your while loop (condition) to, done not equal !== to count. Reset your challenge and try again.
@haahinnawy

Thank you. That is it. Thanks for the information about the comma operator.

2 Likes

Your welcome. Congratulations on passing the challenge.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.