Solo flight keeps crashing, please help!


#1


https://www.codecademy.com/courses/javascript-beginner-en-ASGIv/1/2?curriculum_id=506324b3a7dffd00020bf661


get an infinite loop; browser tab crashes.


`

Replace this line with your code.

var count = 1;
var soloLoop = function(){
//Your code goes here!
while (count = 1){
console.log ("Looped once!");
count = 0;
}

};

soloLoop();

When I run this code, the page becomes unresponsive. Don't understand why it's crashing if I am changing the count variable to false.


#2

So I changed the 'while (count=1)' to 'while (count)' and that did the trick. ┬┐Como? My thinking is that 'count=1' would be a condition that couldn't change, b/c 'count=1' will always equal 1 even though I put the condition of changing the count to 0?


#3

while(count=1) is always true, no matter what the value for count is. since you assign a value of 1 to count:

while(1)

so then count is one, one is considered true, so you have a infinity loop. If you want to compare 1 with count you will have too use two equal signs:

while(count == 1)

now you compare count with 1.

the reason this:

while (count)

will work, is because 0 is considered false. While one is considered true


#4

Makes sense, thanks!!