I have a 2d array like this:
var arr = [[2,3],[5,8],[1,1],[0,9],[5,7]];
Each index stores an inner array containing the coordinates of some
Not a complete answer just a side note that may help.
Use Lodash
This method will get you the position of a value within a 2 dimensional array
let a = [ [ 'bird' ], [ 'cat' ], [ 'dog' ], [ 'cow' ], [ 'bird' ] ];
let b = _.findIndex(a, function(el) { return el[0] == 'cow'; });
console.log(b);//answer is 3
As mentioned earlier you need a nested loop for traversing through the array.