sum
This commit is contained in:
parent
21e205782b
commit
b4b48956cd
@ -1,4 +1,18 @@
|
||||
export function sum(values) {
|
||||
// implementar logica aqui
|
||||
|
||||
let soma = 0;
|
||||
for (let index = 0; index < values.length; index += 1) {
|
||||
soma = soma + values[index];
|
||||
}
|
||||
return soma;
|
||||
}
|
||||
console.log(sum([])); //(0)
|
||||
console.log(sum([1])); //(1)
|
||||
console.log(sum([1, 2])); //(3)
|
||||
console.log(sum([1, 2, 3])); //(6)
|
||||
console.log(sum([1, 2, 3, 4])); //(10)
|
||||
console.log(sum([1, 2, 3, 4, 5])); //(15)
|
||||
console.log(sum([4, 6, 12, 5])); //(27)
|
||||
console.log(sum([9, 234, 312, 999, 21, 2311])); //(3886)
|
||||
console.log(sum([533, 234, 23423, 32, 48876])); //(73098)
|
||||
console.log(sum([-1, 5, -10, -45]))//(-51)
|
||||
console.log(sum([-2, -7, -31]))//(-40)
|
||||
|
Loading…
Reference in New Issue
Block a user