1var number = 12354987,
2 output = [],
3 sNumber = number.toString();
4
5for (var i = 0, len = sNumber.length; i < len; i += 1) {
6 output.push(+sNumber.charAt(i));
7}
8
9console.log(output);
10
11/* Outputs:
12 *
13 * [1, 2, 3, 5, 4, 9, 8, 7]
14 */
1for (var i = 0, sum = 0; i < output.length; sum += output[i++]);
2console.log(sum);
3
4/*
5 * Outputs: 39
6 */