Добавить даже числа рекурсив JS
const recursiveEvenSum = (num, sum = 0) => {
num = num % 2 === 0 ? num : num - 1;
if(num){
return recursiveEvenSum(num - 2, sum+num);
}
return sum;
};
console.log(recursiveEvenSum(12));
console.log(recursiveEvenSum(122));
console.log(recursiveEvenSum(23));
console.log(recursiveEvenSum(10));
console.log(recursiveEvenSum(19));
Sore Seahorse