To learn it, you gotta 'do' it unexpected output and expected infinite loop


#1

var getToDaChoppa = function(number){
// Write your do/while loop here!
do { console.log(number + "is a number!")
}
while (number > 2) {
console.log("It is also bigger than 2");
false
};
}
getToDaChoppa();

When i give getToDaChoppa() value of 1(or any number not higher than 2) it does the while statememnt even though i don't want it to but otherwise i pass the lesson (and i shouldn't) , but when i give it a value that is greater than 2 then i get an infinite loop i really need help from somebody on this.


#2

You incorrectly made a do-while loop. Syntax:

do {
    //Statements
    //Increment/Change Condition
} while (condition);

#3

Could you show me an example with the existing code because i don't fully understand the error


#4

do {
    console.log(number + " is a cool number!");
    number++;
} while (number < 100);

#5

Oh i misunderstood the entire concept . So if i write a while loop it will run when the conditions meet if i write a do/while loop the do part will keep running infinitely until the while condition is met ? Hence no command is written after the while condition ? p.s. is it possible to write a additional command after the while condition for it to additionally do something when the do/while loop stops ?


#6

var getToDaChoppa = function(number);{
// Write your do/while loop here!
do { console.log(number + "is a number less than two!")
number++;
}
while(number < 2);
}
getToDaChoppa(1);

So i did it like this . But i get syntax error and for the love of god i don't understand why


#7

No semicolon needed.