Thursday, September 5, 2013

how do I find the id of the minimum value of an array?

how do I find the id of the minimum value of an array?

I know that you can have the minimum value of an array by typing
var min = Math.min.apply(null, array)
but this will return the smallest value of an array and not the id of this
one for exemple if I have these values:
array[1] = 24;
array[2] = 45;
I want it to return 1 (the ID holding the minimum value) but idk how to
do, could someone help me with this issue please?

No comments:

Post a Comment