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