How do Functions/Do loops/While loops go together?


I can't think of real world example of how to write these loops together in Lesson 10 of while loops. The only thing that comes to mind is reusing old examples but I feel like I learned nothing by just copying old stuff. How do these loops work together!? What's the point of the function if it doesn't even need to be used in some examples?? I don't understand this concept.

var getToDaChoppa = function(){

do {
while (){



The above keyword is not a statement when written by itself. It must declare a variable.

The above is incorrrect syntax. do..while ends with the condition and a semi-colon:

var condition;
do {
    condition = false;
    console.log("Looped once");
} while (condition);


so the do loop runs it but you didn't equal your variable to false outside the do loop... when you write var condition is that automatically true?


No. It is undefined. We define it inside the function.


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