challenge-algorithms-v2.0-v.../06-sum/index.js

12 lines
205 B
JavaScript
Raw Normal View History

export function sum(values) {
2022-10-28 11:04:17 +00:00
let soma = 0;
for (let i = 0; i < values.length; i++) {
if (values[i].length === 0) {
soma = 0;
} else {
soma += values[i];
}
}
return soma;
}