Can't resolve the problem in the code


var understand = true;

console.log("I'm learning while loops!");
understand = false;


Which problem?


I am not able to guess what I must write between these brackets of while loop.
If I write
while(understand= true)
it gets stuck.
Website stops.


= is assignment.
Don't guess! Find out. If you guess you'll end up with incredibly buggy code as appearing to work and actually doing what you want may be very different things.

A hugely important tool when writing code is a search engine, look up what you want to do, for example: "javascript compare for equality"


When I entered
while(understand != false){

It worked.
what was wrong with
while(understand = true){
It seems somewhat similar!


!= is not equals and = is assignment which is entirely different. What you need to test for is equality

equals and not equals can be used to get the behavior of the other one by negating the result. Both operators exist as they are very common operations. As programmers we very often have to look things up, so to find out what the equals operator is, you'll need to use a search engine which is something you must get comfortable with using whenever there's something you need to look up


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