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

1 Answer

0 votes
const number = 908347;

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

console.log(arr); 


 
   
   
   
   
/*
run:
   
[9, 0, 8, 3, 4, 7]
   
*/

 



answered Jun 22, 2022 by avibootz

Related questions

2 answers 146 views
1 answer 149 views
1 answer 155 views
1 answer 113 views
1 answer 142 views
...