6. Solo flight


#1



If have this infinite loop, can't see what is wrong, please help.


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

soloLoop();


#2

Remove this comparison,


#3

var loopedOnce = true;

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

loopedOnce();

TypeError: loopedOnce is not a function
It still gives this error?


#4

call your function by its name which is soloLoop not loopedOnce :slight_smile:


#5

but then it gives the infinite loop


#6

that's because you need an opening and closing bracket for your for loop,

i.e while loop,

while (CONDITION) {
    //while loop body
}

#7

Yess, that's it, thanks a bunch


#9

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