function processData(input) {
//Enter your code here
var number;
var main = "";
var eve;
var odd;
if (isNaN(input) == false) {
return 1;
}
else {
for (var i = 0; i < input.length; i++) {
if (i == 0 || i % 2 == 0) {
eve += input.charAt(i);
}
else {
odd += input.charAt(i);
}
}
main = eve + " " + odd + "\n";
}
console.log(main);
}
process.stdin.resume();
process.stdin.setEncoding("ascii");
_input = "";
process.stdin.on("data", function (input) {
_input += input;
});
process.stdin.on("end", function () {
processData(_input);
});
If I input Hacker in this, I am supposed to get Hce akr
where the even index chars come first followed by a space and then the odd index chars
But somehow I am getting the following out :
- "undefinedHce undefinedakr "
Any help is appreciated!
Thank you.
