jeudi 16 septembre 2021

How to specify multiple conditions in an array instead of using multiple " | | "

I have an array of conditions

let conditions = [1,3,5,7,9];
let values = [1,2,3,4,5,6,7,8,9,0]

I want

if (values == 1 || values== 3 || values == 5 || values == 7 || values == 9 ){   
  return values * 3  
} else { 
  return value * 2 
}

can someone please help to avoid writing multiple OR Conditions and get this done within 1 statement? Thank you

Aucun commentaire:

Enregistrer un commentaire