[Solved] how to get the position of a number in matrix?


You could do something like this in javascript

var data = [
  [1, 2],
  [3, 4],
  [5, 6]
];

var getPos = function(elem, data) {
  var result="";
  data.forEach(function(value, index) {
    value.forEach(function(v, i) {
      if (v == elem) result += (index + 1) + '-' + (i + 1);
    });
  });
  return result;
}

console.log(getPos(5, data));

solved how to get the position of a number in matrix?