While(zmienna===2) =! while(zmienna)?


#1

why it doesnt work?

var zmienna = 2
while(zmienna){
    console.log("iiasidasidasi")
    zmienna=3}

it should be
var zmienna = 2
while(zmienna===2){
console.log("iiasidasidasi")
zmienna=3}

but you said in lesson 4
"
var bool = true;
while(bool){
//Do something
}
is the same thing as

var bool = true;
while(bool === true){
    //Do something
}

but the first one is faster to type."

and I made the same. Or it just works with true/false only?


#2

It only works with Booleans, true, false, or something that evaluates to either.

In order to use numbers you need to make a comparison with a comparison operator.