How To Use And And Or Operator In Js With Browser Detection
the OR operator does not work after the AND. The logic I need is: If the first select (# pa_modalita-pagamento) has the value 'account-saldo' and the second select (#pa_participant
Solution 1:
You need to use parenthesis if you use AND and OR in the same condition.
if (browser ==='Mozilla Firefox' && (val ==='acconto-saldo' || val === 'partecipanti-1' || val === 'partecipanti-2' || val === 'partecipanti-3' || val === 'partecipanti-4' || val === 'partecipanti-5'))
By the way, you could add all your accepted values into an array and make the if shorter
let participanti = ['partecipanti-1','partecipanti-2','partecipanti-3','partecipanti-4','partecipanti-5'];
if (if (browser ==='Mozilla Firefox' && participanti.includes(val)) {
...
}
Post a Comment for "How To Use And And Or Operator In Js With Browser Detection"