How to compare arrays in JavaScript