Do while Loop - Not sure what i am doing wrong


#1

My browser becomes unresponsive when I am running the below program. I am not able see a reason why it is falling into a infinite loop but apparently it is and i believe my browser goes unresponsive because of that.
My aim here to print numbers from 0 to 10.
var count = 0;
var getToDaChoppa = function(){
// Write your do/while loop here!
do {
console.log(count);
} while (count < 10){
console.log(count)
count++
}

};

getToDaChoppa();


#2

Should work:

var count = 0;
var getToDaChoppa = function(){
   do {
      console.log(count);
      count++;
   } while (count < 10);
};

getToDaChoppa();

Example here:
JavaScript do/while Statement


#3

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