10. To learn it, you gotta 'do' it Infinate Loop?


#1

Have a problem with this being a infinite loop? don't know how??

var ch = true;
var getToDaChoppa = function(){
  do 
  {
console.log("get to thee chopa")
  } 
  
  while(ch); 
  {
      console.log("pleh");
      ch = false;
  }
  
};

getToDaChoppa();


#2

you have two types of while loop, do while:

do {

} while(condition);

and while:

while (condition){

}

you can not combine a do while and a while loop into a do while while loop like you did


#3

ok, But in a do while loop where does the code go that gets executed in the while loop? don't I need another set of { }??

EDIT: NVM I got it working I understand now, you put it back in the do { }. Thanks


#4

here:

do {

} while(condition);

the content of the do while loop has to between the {}


#5

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