duplicated solutions in loops to match themes

This commit is contained in:
2026-01-03 13:44:33 +10:00
parent e6806a2366
commit b6776f93fd
3 changed files with 27 additions and 0 deletions

View File

@@ -1,3 +1,13 @@
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;
}