Infinite do while loop help


#1

var getToDaChoppa = function(){
// Write your do/while loop here!
var numero = 2;
do { console.log("something");
}
while ( numero === 2) {
numero = 3;
};
};

getToDaChoppa();


#2

the problem is that this:

var numero = 2;
  do { console.log("something");
  }
    while ( numero === 2)

is your do while loop and all the stuff that comes after this is only executed after this loop finished and as you can see this is never the case as the condition will always be true. So to stop it get rid of the "pseudo while"-loop and move the change of numero inside of the do while loop.


#3

Thanks, this code worked
var getToDaChoppa = function(){
// Write your do/while loop here!
var numero = 2;
do { console.log("something");
numero = 3;
}
while ( numero === 2) {

};

};

getToDaChoppa();

I thought that the while looped conditions is tested before the loop begins again, is that false?


#5

It is but the thing with the do while loop is that is is the other way around. You first run the code in the {} after do than you test the condition and if it is correct you jump back to do and run the code again aso. So you can fully erase the {}; after while and just replace it with a ; because that is not part of your loop.