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


#1

var loopCondition = "banana";

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


#2

strings are considered true, so this condition:

 while (loopCondition)

will always evaluate to true.


#3

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


#4

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

if ("see"){
   console.log(true)
} else {
   console.log(false)
}

#5

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