How to split a number into an array of digits in TypeScript

1 Answer

0 votes
const number = 875125;

const arr = Array.from(String(number), Number);

console.log(arr); 


 
   
   
   
   
/*
run:
   
[8, 7, 5, 1, 2, 5] 
   
*/

 



answered Jun 22, 2022 by avibootz
...