challenge-algorithms-v2.0-v.../06-sum/index.js
2022-10-28 08:04:17 -03:00

12 lines
205 B
JavaScript

export function sum(values) {
let soma = 0;
for (let i = 0; i < values.length; i++) {
if (values[i].length === 0) {
soma = 0;
} else {
soma += values[i];
}
}
return soma;
}