Answers for "how to separate out numeric value from string in javascript"

3

split the numbers js

var num = 123456;
var digits = num.toString().split('').map(iNum => parseInt(iNum, 10));
console.log(digits);
Posted by: Guest on February-29-2020
0

separate digits in javascript

const n = 123456;
Array.from(n.toString()).map(Number);
// [1, 2, 3, 4, 5, 6]
Posted by: Guest on February-23-2021

Code answers related to "how to separate out numeric value from string in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language