The question is as below:
Write a code get an integer number as input and print the odd and even digits of the number separately.
Input Description:
A single line containing an integer.
Output Description:
Print the even and odd integers of the integer in a separate line.
Sample Input :
1234
Sample Output :
2 4
1 3
My answer is as below:
var a = userInput[0].split('').map(Number);
var result = "";
for(var i = 0; i<a.length; i++){
if(a[i]%2===0){
result = result + a[i];
}
}
console.log(result+" ");
I am getting half of my answer correct.
Kindly help to solve this problem properly.