dimanche 19 mai 2019

A problematic if statement in Javascript

I have an if statement with two conditions and an or operator between them, it evaluates to be true after only one condition.

because I used the || operator it checks the first condition and if it is true it will go into the if statement without checking the second one.

if (checkPassword() == true || checkUserName() == true) evenet.preventDefault();

I expect it to go into the checkUserName function because there are crucial things in it that needs to be done, I can do it the long way but it will be cool if there is a way to make the if statement check the second condition even though it has the || operator and that's how programming works ( as far as I know)

Aucun commentaire:

Enregistrer un commentaire