Do/while loop outside a function


All of the do/while loops in the exercises are places inside an undefined function, e.g.:
var getToDaChoppa = function(){
// Write your do/while loop here!


Is it strictly necessary to have this outer function? If not, what is then the difference of the two? And what about the difference between placng my variable inside and outside the function?


No, it is not. You can have a do/while loop or a for loop outside a function.

They are roughly the same, except that a function is a block of code you can call with a function call (getToDaChoppa();)

No huge difference, only you have to be careful with your variable scope (local vs global). Hope this helps.


Yes, I think I understand now. Thank you.