function getAlter(arr, idx, res){
if(idx < arr.length){
res.push(arr[idx]);
getAlter(arr, idx + 2, res);
}
}
function getAltertwo(arr){
let res = [];
getAlter(arr, 0, res);
return res;
}
const arr = [10,20,30,40,50];
let res = getAltertwo(arr);
console.log(res);// your code goes here
ZnVuY3Rpb24gZ2V0QWx0ZXIoYXJyLCBpZHgsIHJlcyl7IAoJaWYoaWR4IDwgYXJyLmxlbmd0aCl7IAoJCXJlcy5wdXNoKGFycltpZHhdKTsgCgkJZ2V0QWx0ZXIoYXJyLCBpZHggKyAyLCByZXMpOyAKCX0KfQoKZnVuY3Rpb24gZ2V0QWx0ZXJ0d28oYXJyKXsKCWxldCByZXMgPSBbXTsKCWdldEFsdGVyKGFyciwgMCwgcmVzKTsKCXJldHVybiByZXM7Cn0KCmNvbnN0IGFyciA9IFsxMCwyMCwzMCw0MCw1MF07CmxldCByZXMgPSBnZXRBbHRlcnR3byhhcnIpOwpjb25zb2xlLmxvZyhyZXMpOy8vIHlvdXIgY29kZSBnb2VzIGhlcmU=