I have created a matrix like:
u = Array.from({ length: 100}, (v, i) => []);
console.log(u)
Then, after running the code and filling the matrix. I wanted to get the index of the minimum element in particular row.so the result should be either 0 or 1.
act[i] = u.indexOf(Math.min.apply(null,u[i]));
However, I get -1 sometimes. I read that negative number means the element does not exist in the array. In my case it always exist.
to check that it exist I used console.log()
and it does always exist but for some reason it still return -1 as an index.