'while' loops in JS - to learn it you got to 'do' it


Guys I am a bit lost form the beginning here! Please can someone kick start me with this one...

var getToDaChoppa = function();



  • I don't know where to start as the example before hand starts var loopCondition = false;


Start by writing the correct syntax...

var getToDaChoppa = function() {  // <<<


Note the removed semi-colon which does not belong, and the added opening curly brace on the function body.


Hi, thank you - i have been fiddling with this one for a while and i cannot grasp it.
The below is as far as i've got but i do not know whether the "do" is correct and or what to put in "while"

var getToDaChoppa = function(){
do {
console.log("I am the Terminator");
} while();

for obvious reasons it return - Oops, try again. There was a problem with your syntax.


If you want the loop to stop at some point, a variable will need to be defined and tested in the while()

var condition;
do {
    // some code to run
    condition = false
} while (condition);


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