i am trying to handle with an array with non-consecutive numbers . Here is my example var myArray = [2, 4, 6, 8]
. absent numbers are 3, 5, 7 and the quantity = 3
. I tried to get it with this function `
function makeArrayConsecutive(myArray) {
return Math.max(myArray) - Math.min(myArray) + 1 - myArray.length;
}
var myArray = [2, 4, 6, 8];
console.log(makeArrayConsecutive(myArray));
this must return 3 ... but it returns NaN... whats the issue ?