Answers for "javascript consecutive numbers in array"

2

javascript consecutive numbers in array

/**
 * Given an array of number, group algebraic sequences with d=1
 * [1,2,3,4,5,6] => true
 * [1,2,4,5,6] => false
 */
 var arr = [1,2,4,5,6];
 const differenceAry = arr.slice(1).map(function(n, i) { return n - arr[i]; })
 const isDifference= differenceAry.every(value => value == 1)
 console.log(isDifference);			// False
Posted by: Guest on May-22-2021

Code answers related to "javascript consecutive numbers in array"

Code answers related to "Javascript"

Browse Popular Code Answers by Language