I have an array that I'm trying to compare to see if the values in array 1 are in any of the arrays inside an object:
arr1 = [9]
obj1 = {Cards: [8,5], Loans: [], Shares: [0,9,25]}
I'm using JavaScript(ECMAScript 5) to try and do this, all I need is true to be returned if any of the values in arr1 are found inside obj1.
What I've tried:
function arraysEqual(_arr1, _arr2) {
if (!Array.isArray(_arr1) || !Array.isArray(_arr2) || _arr1.length !== _arr2.length)
return false;
var arr1 = _arr1.concat().sort();
var arr2 = _arr2.concat().sort();
for (var i = 0; i < arr1.length; i++) {
if (arr1[i] !== arr2[i])
return false;
}
return true;
}
This however will just test to see if the arrays in specific so I have to call this three times to check the values, even this however will return false when I try:
arraysEqual(arr1, obj1.Shares)
Would like this to be done with one call