how to convert number to array in javascript using Array.from code example
Example 1: turn number into array javascript
const myNumber = 1245;
function numberToArray(number) {
let array = number.toString().split("");
return array.map(x => parseInt(x));
}
var myArray = numberToArray(myNumber);
Example 2: number to array javascript
const n = 123456;
Array.from(n.toString()).map(Number);
Example 3: number to array js
const arrayOfDigits = numToSeparate.toString().split("");
Example 4: how to convert number to array in javascript using Array.from
const n = 123456;
Array.from(n.toString()).map(Number);