Infinite loop?


#1


Link


My browser is crashing everytime I perform this code and I cannot find a problem with it.


var boolean = true

while( boolean = true )
{ console.log(" this is a while loop")
  boolean = false 
}
 
for(var n = 1; n < 5 ;  n += 3)
{
   console.log( "this is a for loop")
}


#2

here:

while( boolean = true )

a single equal sign means assign, so then you get this:

while(true)

which is an infinity loop, maybe it is an idea to check if boolean and true are equal?


#3

Thank you. I can't believe I misssed that.


#4