Is there a way to determine if an array's members are consecutive?
For instance, the array [1,3,4,5,6] is not considered consecutive because it is missing the number 2 in the sequence. Which JavaScript array methods can be used to check for this type of pattern?
I've experimented with JavaScript array methods like ".map", ".every", and ".some", but haven't had any success.
let values = [1,3,4,5,6];
let result1 = values.map(x => x > 5);
console.log('value of result1 : ', result1);
Result: "value of result1 : ", [false, false, false, false, true]
let result2 = values.some(x => x > 5);
console.log('value of result2 : ', result2);
Result: "value of result2 : ", true
let result5 = values.every(x => x > 4);
console.log('value of result5 : ', result5);
Result: "value of result5 : ", false
Thank you...