I can create like that code in js? if example == 0, 2, 4, 6, 8 { code here } else if { code here } I mean check example have one of this value
I dont wanna create many lines code example if == 0 , if == 2 ets Thanks for help
Advertisement
Answer
I think what you want to do is compare your ‘example’ with each of the values.
let’s assume your array is 2,4,6,8,0
then what you can do is
let example = 3; let array = [2, 4, 6, 8, 10]; if (array.includes(example)) { // true statement } else { // false statement }