What does (true === false) means in the screenshot of the code and what is the purpose of it in this code?

the comparisons result in false, stopping the loop.

personally, i would then just do:

while (false)

normally, these conditions would be more meaningful. Like checking that the user input is valid or something, so that the loop keeps prompting until the users enters something valid

while(false) and while(true === false) represent the same condition?

conditions have been taught, surely?

while(false) isn’t a condition, false is just a Boolean value to stop the loop.

but these “conditions” aren’t representative for real world code, they are just there to stop the loop

The ‘==’ operator tests for abstract equality i.e. it does the necessary type conversions before doing the equality comparison.
But the ‘===’ operator tests for strict equality i.e it will not do the type conversion hence if the two values are not of the same type, when compared, it will return false.

The loop will never run. A while condition can never be false.

Comparing true to false is moot, just as comparing black to white, or 0 to 1. They are diametrically opposed and can never be equated.

I also thought like You that true === false is not possible. But I have shared the screenshot of tutorial of codecademy of Loop section (do while)

but sadly the program is running.

then why the program writes while(true === false) instead of while(false) or while(!true) ?

1 Like

just an example that will equate to false, like ( 1 === 0), dont get hung up on it, like me thinking of a good way to answer it :blush:


why is that not possible? Its a comparison, that will result in false. Its quite odd and uncommon.

in the screenshot of the code, can You tell when the comparison will result in false?
I am still trying to grasp it.

I recommend to run your code here:


so you can “walk” through it.

Do you not understand the comparison operator?

Do you not understand the while or do/while loop?

I am just struggling to see what you don’t understand.

here is some documentation: