This question already has an answer here:
In JavaScript, how do I test that one array has the elements of another array?
arr1 = [1, 2, 3, 4, 5]
[8, 1, 10, 2, 3, 4, 5, 9].function_name(arr1) # => true
This question already has an answer here:
In JavaScript, how do I test that one array has the elements of another array?
arr1 = [1, 2, 3, 4, 5]
[8, 1, 10, 2, 3, 4, 5, 9].function_name(arr1) # => true
You can use array.indexOf():
pseudocode:
No set function does this, but you can simply do an ad-hoc array intersection and check the length.
A more efficient way to do this would be to use
.every
which will short circuit in falsey cases.