Been trying to figure out how to do this for a while, but haven't had any success yet. If I have 2 arrays like this:
array1 = [
{ name: 'John', age : 25},
{ name: 'Jane', age : 58}
]
array2 = [
{ name: 'Jane', age : 58},
{ name: 'John', age : 25}
]
How can I chech if array1 contains all the elements of array2? Note - the ordering doesn't matter, I want to be able to write something like this:
if array1.containsAll array2
console.log 'array1 contains all of the elements in array2'
else
console.log 'array1 does not contain all of the elements in array2'
I've tried using the contains function, but I get an error like this:
Object .... has no method 'contains'