Horje
javascript consecutive numbers in array Code Example
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
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);	




Javascript

Related
mongoose connection Code Example mongoose connection Code Example
how to create a button with react Code Example how to create a button with react Code Example
clear canvas for redrawing Code Example clear canvas for redrawing Code Example
select tag onchange Code Example select tag onchange Code Example
reactjs get checkbox value Code Example reactjs get checkbox value Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7