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

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

javascript - jquery or ashx not working -

inno setup - TLabel or TNewStaticText - change .Font.Style on Focus like Cursor changes with .Cursor -