challenge-algorithms-Ana-Ca.../07-soma-dos-pares/index.html

31 lines
808 B
HTML
Raw Normal View History

2021-08-18 21:00:43 +00:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
/*
Faça um algoritmo que retorne a soma de todos os numeros pares de um array
*/
function sum(numbers) {
// implementar logica aqui
return 0
}
// Resultados esperados
console.log(sum([4, 6, 12, 5]), 22) // 22
console.log(sum([9, 234, 312, 999, 21, 2311]), 546) // 546
console.log(sum([533, 234, 23423, 32, 48876]), 49142) // 49142
console.log(sum([5, 4, 3, 2, 1]), 6) // 6
</script>
</body>
</html>