这串数字是连续的吗?
- 内容介绍
- 文章标签
- 相关推荐
本文共计110个文字,预计阅读时间需要1分钟。
判断数组是否是连续数字的简化版开头内容:
javascriptfunction isContinuous(arr) { arr.sort((a, b)=> a - b); const n0=arr[0]; let bool=true; arr.forEach((item, index)=> { if (item !==index + n0) { bool=false; } }); return bool;}
gistfile1.txt//判断数组是否是连续数字 此方法只针对是纯数字的数组 isContinuous = (arr) => { arr.sort((a, b) => a - b) const n0 = arr[0] let bool = true arr.forEach((item, index) => { if(item !== index+n0){ bool = false } }) return bool }
本文共计110个文字,预计阅读时间需要1分钟。
判断数组是否是连续数字的简化版开头内容:
javascriptfunction isContinuous(arr) { arr.sort((a, b)=> a - b); const n0=arr[0]; let bool=true; arr.forEach((item, index)=> { if (item !==index + n0) { bool=false; } }); return bool;}
gistfile1.txt//判断数组是否是连续数字 此方法只针对是纯数字的数组 isContinuous = (arr) => { arr.sort((a, b) => a - b) const n0 = arr[0] let bool = true arr.forEach((item, index) => { if(item !== index+n0){ bool = false } }) return bool }

