📜  数字拆分 2 - Javascript 代码示例

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

代码示例1
const num = 1234567;
const strNum = String(num);
const result = [];

for (let i = 0; i < strNum.length - 2; ++i) {
  result.push(strNum.slice(i, i + 3));
}
console.log(result);
 Run code snippet