I want to log the min and max number from an array of numbers, that keep changing on runtime.
I am using ES5 Math.min
and Math.max
. I even clone the input array to avoid concurrent changes. This is my code:
var runTimes = input.runTimes.slice(0); // clone input to avoid further changes
console.log("RUN TIMES", runTimes);
var min = Math.min(runTimes);
var max = Math.max(runTimes);
console.log("RUN TIMES MIN", min);
console.log("RUN TIMES MAX", max);
I get NaN
even though all items are numbers, verified by the log: