Review---"do/while"


#1


https://www.codecademy.com/zh/courses/javascript-beginner-en-ASGIv/2/4?curriculum_id=506324b3a7dffd00020bf661#

Sorry, i still don't understand the "do/while" false condition quite well, can anyone point out where i got wrong in my codes, and also make an example of "do/while" for me?(Especially the false condition, really appreciate !)

// Write your code below!
for (var i =0; i<50; i+=5 ) {
    console.log(i) 
}

var condition = true;
while (condition) {
    console.log("We will keep looping!");
    condition = false;
}

var condition = false;
do {
    console.log("We will only do the loop once!");
} while { condition = false}


#2

2 errors in your

var condition = false;
do {
    console.log("We will only do the loop once!");
} while { condition = false}

should be

var condition = false;
do {
    console.log("We will only do the loop once!");
} while ( condition )

The Instructions:
To finish up and prove your loop mastery,
write three syntactically correct loops in the editor:
one for,
one while, and one do. Beware of infinite loops!

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 while site:developer.mozilla.org
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/while

== discussions / opinions ==
javascript while vs do while site:stackoverflow.com
http://stackoverflow.com/questions/5599027/the-do-while-statement

== guidance ==
www.crockford.com
http://javascript.crockford.com/code.html <== code convention
http://javascript.crockford.com/survey.html
https://developer.mozilla.org/en-US/docs/Web/JavaScript/A_re-introduction_to_JavaScript


#3

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