If statement runs through whether conditions are met or not

后端 未结 4 1289
北海茫月
北海茫月 2021-01-28 17:13

My if statement runs through as if the conditions have been met even when they haven\'t. I have tried moving bits of code about and even rewriting the if statement differently b

4条回答
  •  逝去的感伤
    2021-01-28 17:25

    This is really bogus

    if (bob == "no", "No", "NO", "nO")
    

    You need to break it out with logical OR instead

    if (bob == "no" || bob == "No" || bob == "NO" || bob == "nO")
    

    As it stand, this if (bob == "no", "No", "NO", "nO") would be equivalent to if("nO") as the effect of the comma operator.

提交回复
热议问题