I stored several coordinate pairs in a single array. For example:
[[1,2],[4,5],[7,8]]
I'd like to find the coordinate pair that I got. I got coordinate:
[4,5]
If array contains this coordinates that I'll get true otherwise false. This is my code:
function isContain(coords) {
for (let i = 0; i < array.length; i++) {
if (array[i].length !== coords.length) return false;
for (let j = 0; j < array[i].length; j++) {
if(array[i][j] === coords[j]) {
return true
}
}
}
return false
}