[Solved] Find next increment value in array JavaScript


For this you can create a new array where you can store the desired values. Then loop (in this case from 0 to 15) and check if the number is in the array-array. If it is not in the array, you can store the value in the values-array.

var array = [2, 4, 5, 8, 11];
var values = [];

for (var i = 0; i <= 15; i++) {
  if (!array.includes(i))
    values.push(i);
}

console.log(values); // Output: [0, 1, 3, 6, 7, 9, 10, 12, 13, 14, 15]

0

solved Find next increment value in array JavaScript