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 123 views
2 answers 285 views
2 answers 163 views
1 answer 127 views
2 answers 175 views
...