Answers for "how to split a number into individual digits 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
2

how to split two digit number in javascript

var number = 12354987,
    output = [],
    sNumber = number.toString();

for (var i = 0, len = sNumber.length; i < len; i += 1) {
    output.push(+sNumber.charAt(i));
}

console.log(output);

/* Outputs:
 *
 * [1, 2, 3, 5, 4, 9, 8, 7]
 */
Posted by: Guest on April-09-2020
0

split integer into digits javascript

var n =  123456789;
var digits = (""+n).split("");
Posted by: Guest on August-14-2021

Code answers related to "how to split a number into individual digits in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language