Do/While Loops


#1

I'm getting the hang of the different loops but have a question about my code. The code below works correctly but was crashing because I had the ending

getToDaChoppa(0) instead of the correct getToDaChoppa(1).

In an earlier lesson I needed to make my beginning variable, in this case "cats(0)"; equal to the number inside the () at the ending function. Can someone please explain in depth why my ending getToDaChoppa(1) needs to have (1) instead of (0), and why it was opposite in the earlier exercise. I really want to understand this in depth, thank you! Here is my working code:

var cats = 0
var getToDaChoppa = function(cats){
do { console.log("Get Dowwwwwwn!");
}
while (cats === 0) {
console.log("I can't make it!");
cats = 1;
}

};

getToDaChoppa(1);


#2

@sgruse,

You cannot combine the do-while-loop and the while-loop
like you are doing....

the for-loop:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for

the while-loop:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/while

the do-while-loop:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/do...while

Reference

google search
== the Book ==
javascript [your question] site:developer.mozilla.org

== discussions / opinions ==
javascript [your question] site:stackoverflow.com

== guidance ==
www.crockford.com
http://javascript.crockford.com/code.html
http://javascript.crockford.com/survey.html
= http://stackoverflow.com/questions/9549780/what-does-this-symbol-mean-in-javascript
https://developer.mozilla.org/en-US/docs/Web/JavaScript/A_re-introduction_to_JavaScript
www.developer.mozilla.org/en-US/docs/Web/JavaScript/Guide
= http://stackoverflow.com/questions/336859/var-functionname-function-vs-function-functionname?rq=1