13 lines
274 B
JavaScript
13 lines
274 B
JavaScript
sum = function(...args) {
|
|
return args.filter(num => num % 2 !== 0).reduce((acc, num) => acc + num, 0);
|
|
}
|
|
|
|
sum = function(...args) {
|
|
let total = 0;
|
|
for (let num of args) {
|
|
if (num % 2 !== 0) {
|
|
total += num;
|
|
}
|
|
}
|
|
return total;
|
|
} |