Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

find consecutive numbers in an array javascript

let arr = [1,2,4,5,6];
let differenceAry = arr.slice(1).map(function(n, i) { return n - arr[i]; })
let isDifference= differenceAry.every(value => value == 1)
console.log(isDifference);	
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #find #consecutive #numbers #array #javascript
ADD COMMENT
Topic
Name
1+9 =