I'm trying to determine if two arrays (a and b in the code below) are identical.
I've written the code below, but the for loop breaks after it returns a 'true' value for any array element.
function arraysEqual(a, b) {
if (a === b) return true;
for (var i = a.length; i--;) {
if (a[i] !== b[i]) return false;
}
return true;
}
I think that I need to run an every() function but I can't figure out how to define the function to check identity between the arrays.
Thank you in advance.