My Function Is Broken It Seems Javascript -


basically no matter enter when call function says have fled. may overlooking can't figure out what.

    function attack() { var battle = prompt("attack of flee?") if (battle === "flee" || "flee") {     alert("you have fled");     }  else if (battle === "attack" || "attack"){     alert("you have attacked"); }        } 

try if (battle === "flee" || battle === "flee") right hand side evaluating string "flee" truthiness, evaluates true.


Comments

Popular posts from this blog

hibernate - How to load global settings frequently used in application in Java -

python 3.x - Mapping specific letters onto a list of words -

objective c - Ownership modifiers with manual reference counting -