number to array javascript
const myNumber = 1245;
function numberToArray(number) {
let array = number.toString().split("");//stringify the number, then make each digit an item in an array
return array.map(x => parseInt(x));//convert all the items back into numbers
}
//use the function
var myArray = numberToArray(myNumber);const numToSeparate = 12345;
const arrayOfDigits = Array.from(String(numToSeparate), Number);
console.log(arrayOfDigits); //[1,2,3,4,5]Array.from(String(12345), Number);const n = 123456;
Array.from(n.toString()).map(Number);
// [1, 2, 3, 4, 5, 6]
const arrayOfDigits = numToSeparate.toString().split("");
Also in JavaScript:
- Javascript track mouse pointer
- js loop ul
- discord.js send message to specific channel
- how to prevent previous radio button active react native
- jquery dialog button text set by variable
- send json post ajax javascript
- js select element by css selector
- passing a variable to the width style div angular
- react.strictmode
- json placholder
- react-native-screens
- react ctx
- command reboot android app react native adb command
- how to hide header in react navigation
- get element by id in javascript
- npm stop react app
- Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.40/containers/json: dial unix /var/run/docker.sock: connect: permission denied
- upload bloob javascript
- Module Error (from ./node_modules/eslint-loader/dist/cjs.js):
- javascript submit form when enter key pressed
- javascript get browser is electron
- hidden jquery
- localecompare javascript
- jquery check checkbox