Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

check if numbers are consecutive javascript

 /**
 * 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
Comment

PREVIOUS NEXT
Code Example
Javascript :: ajax onchange dropdown 
Javascript :: node.js express post query string 
Javascript :: Error: Not implemented: window.alert 
Javascript :: moment timezone set default timezone 
Javascript :: check online status javascript 
Javascript :: javascript falsy 
Javascript :: javascript reverse string 
Javascript :: custom event js 
Javascript :: javascript right trim 
Javascript :: set a value in session using javascript 
Javascript :: javascript eval passing variable 
Javascript :: keep-alive vuejs router 
Javascript :: cypress foreach li 
Javascript :: first repeated character in a string javascript 
Javascript :: viewmodelprovider example 
Javascript :: binary gap 
Javascript :: ubuntu 18.04 nodejs insatll 
Javascript :: array without duplicates js 
Javascript :: hex to rgb function 
Javascript :: set default date today js 
Javascript :: regex string case insensitive 
Javascript :: disable mixed content via javascript 
Javascript :: dart code formatter vscode 
Javascript :: determine text truncate javascript 
Javascript :: javascript tick marks 
Javascript :: find positive integers javascript 
Javascript :: var vs let js 
Javascript :: uploading file with fetch 
Javascript :: array_diff in jquery 
Javascript :: or inside if javascript 
ADD CONTENT
Topic
Content
Source link
Name
6+6 =