6. Solo Flight HELP!


#1



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


The error says 'Oops, try again. Did you log 'Looped once!' to the console?

Isn't that what I did? What did I do wrong?


//Remember to make your condition true outside the loop!
var mycondition = true;

var soloLoop = function(){
  while(mycondition) {
      console.log("Looped once!");
      var mycondition = false;
  }
  
};

soloLoop();


#2

@betasolver89106,
Try it with

var soloLoop = function(){
    //define a =local= VARIABLE mycondition
    var mycondition = true;
    while(mycondition) {
        console.log("Looped once!");
        //change the VALUE of allready declared VARIABLE
        mycondition = false;
  }
  
};

instead of your usage of a =global= variable outside of your function
and by using a var condition inside of your function you are =shadowing=
the condition variable


#3

You are supposed to set the variable condition outside of the loop before it, as it says in the instructions. Keeps crashing my browser.


#4

It's still setting the variable condition outside the loop. It's inside the function but outside the loop. The way he has it, the variable is declared before the while loop. It sill meets the criteria.


#5

Thanks, you helped me a lot.

var myCondition = true;
var soloLoop = function(){
var myCondition = true;
while(myCondition){
console.log("Repetiu uma vez!");
myCondition = false;
}
};

soloLoop();