I wish to check that all the values in event
are included in state
. Is so the function should return true, else false. What is a nice way of doing this?
const state = [1,2,4,5,6,7]
const event = [1,2]
if(state.contains(event))(}
I wish to check that all the values in event
are included in state
. Is so the function should return true, else false. What is a nice way of doing this?
const state = [1,2,4,5,6,7]
const event = [1,2]
if(state.contains(event))(}
You can use every()
and includes()
array methods:
const state = [1, 2, 4, 5, 6, 7];
const event = [1, 2];
console.log(event.every(x => state.includes(x)));