why to stop looping is necessary
Answers
Answered by
0
while(loopCondition) means run the loop while loopCondition is true just like in a regular while loop, the difference for a do while loop is that you run the condition after executing what's inside the loop so for the first time you execute it without condition, after this it is just a while loop written a bit differently. for example
console.log("I'm gonna stop looping 'cause my condition is " + loopCondition + "!"); while (loopCondition) { console.log("I'm gonna stop looping 'cause my condition is " + loopCondition + "!"); }
and
do { console.log("I'm gonna stop looping 'cause my condition is " + loopCondition + "!"); } while (loopCondition);
do the exact same thing, the only difference is that you don't have to write
console.log("I'm gonna stop looping 'cause my condition is " + loopCondition + "!");
twice and if you think of an even bigger loop body that alone might be interesting.
console.log("I'm gonna stop looping 'cause my condition is " + loopCondition + "!"); while (loopCondition) { console.log("I'm gonna stop looping 'cause my condition is " + loopCondition + "!"); }
and
do { console.log("I'm gonna stop looping 'cause my condition is " + loopCondition + "!"); } while (loopCondition);
do the exact same thing, the only difference is that you don't have to write
console.log("I'm gonna stop looping 'cause my condition is " + loopCondition + "!");
twice and if you think of an even bigger loop body that alone might be interesting.
Answered by
0
If we don't stop a loop it goes on infinitely
Similar questions