feat(sum):criado algoritimo de soma

This commit is contained in:
Tiago Trevisani 2022-11-02 15:40:30 -04:00
parent eb6baaa927
commit 696061d9ba
3 changed files with 28 additions and 6 deletions

View File

@ -1,4 +1,17 @@
export function maxValue(values) {
// implementar logica aqui
}
const values = [4, 6, 12, 5];
const values = [9, 234, 312, 999, 21, 2311];
const values = [533, 234, 23423, 32, 432];
const values = [5, 4, 3, 2, 1];
const values = [-1, -5, -10, -45];
const values = [];
const maxValue = values.reduce(function(prev, current) {
return prev > current ? prev : current;
});
return Math.max(values);
}

View File

@ -1,4 +1,4 @@
export function isPrime(value) {
// implementar logica aqui
}

View File

@ -1,4 +1,13 @@
export function sum(values) {
// implementar logica aqui
var arr = [1];
var arr = [1, 2];
var arr = [1, 2, 3];
var arr = [1, 2, 3, 4,];
var arr = [1, 2, 3, 4, 5,]
var sum = 0;
for(var i = 0; i < values.length; i++) {
sum += values[i];
}
return sum
}