📌  相关文章
📜  检查数字是否是连续的javascript代码示例

📅  最后修改于: 2022-03-11 15:03:54.228000             🧑  作者: Mango

代码示例1
/**
 * 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