I'm trying to check for array equality using forEach
in JavaScript. This criteria is key, and the answer is not on Stack Overflow already.
The tests that are checking equality and expecting true
are failing. I have a feeling I'm running into an issue to do with scope. Can someone please walk me through it?
function eql(arr1, arr2) {
arr1.forEach((el) => {
if (arr1[el] === arr2[el]) {
return true;
}
})
return false
}
Here are the test results I want to change:
eql([], [])
Expected: true but got: false
eql(['a', 'b'], ['a', 'b'])
Expected: true but got: false