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

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -