What's wrong with this do/while code of mine...it should print the console once by do condition though its wrong for while


var loopCondition = "banana";

do {
console.log("I'm gonna stop looping 'cause my condition is " + loopCondition + "!");
} while (loopCondition);


strings are considered true, so this condition:

 while (loopCondition)

will always evaluate to true.


oh! thanks man...didn't know strings are considered true??


if you are not comparing them to anything, they are evaluate to true:

if ("see"){
} else {


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