GUVI
Back

how to solve

Created 2 years ago
39 Views
2 Comments
RamkiAm156B
@RamkiAm156B
RamkiAm156B
@RamkiAm156BProfile is locked. Login

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.

const readline = require('readline');

const inp = readline.createInterface({

input:process.stdin

});

let userInput;

inp.on("line", (data)=>{

userInput = data;

});

let oddArray = [];

let evenArray = [];

inp.on("close", () =>{

let k = userInput.split('');

for(i=0; i<k.length; i++){

if(parseInt(k[i]) % 2 === 0){

evenArray.push(k[i]);

}

else {

oddArray.push(k[i]);

}

}

console.log(evenArray.join(' '));

console.log(oddArray.join(' '));

});

i got error?

Sample Input :
1234
Sample Output :
2 4
1 3
Comments (2)
Please login to comment.
 
Powered by habitate.io Habitate