Print the digits of the integer in a single line separated by space.
Created 2 years ago
1706
Views
4
Comments
var a = userInput[0].split(" ");
var sum = 0;
var str =" ";
while (a) {
sum = a % 10;
str+=sum+" ";
a = Math.floor(a / 10);
}
console.log(str);
i/p :123
bt i m getting reversed output 3 2 1.
Expected o/p : 1 2 3 help me solve this.