I am trying to get the highest number from a simple array:
data = [4, 2, 6, 1, 3, 7, 5, 3];
alert(Math.max(data));
I have read that if even one of the values in the array can't be converted to number, it will return NaN
, but in my case, I have double-checked with typeof
to make sure they are all numbers, so what can be my problem?