How to split a number into an array of digits in Node.js

1 Answer

0 votes
const number = 802261;

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

console.log(arr); 

 
   
   
   
   
/*
run:
   
[ 8, 0, 2, 2, 6, 1 ]
   
*/

 



answered Jun 22, 2022 by avibootz

Related questions

1 answer 134 views
2 answers 300 views
2 answers 170 views
1 answer 137 views
2 answers 182 views
...