6. Solo Flight - help!


#1


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


Infinite Loop :frowning:


var myCondition = true
var soloLoop = function(){
  //Your code goes here!
  while (myCondition = true){
      console.log("Looped once!");
      myCondition = false;
  }
};

soloLoop();

THANKS!


#2

This code:

myCondition = true

changes value of myCondition to true. It's fine, but this statement always returns true, so it should not be used as a condition in the while loop. It's never a good idea to use assign operation as a condition.

You should use one of the comparison operators (>, <, >=, <=, ===, !==, ==, !=) instead of =.


#3

I've edited these statements now to ==, but I still get the infinite loop - what's causing this? Thanks! :slight_smile:


#4

Please post your code after correction. I don't see any other errors. And your code should work fine, take a look -> https://repl.it/Dp16/0


#5

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