Created
October 25, 2022 14:25
-
-
Save sauerlock/149ad93ea20b2e6f2b9cf368a8d3870c to your computer and use it in GitHub Desktop.
Exercicio 4 - Arrays
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Crie uma função que receba um array de números retorne a soma dos primeiros 5 números ímpares desse array. | |
const numbers = [1, 3, 4, 5, 7, 8, 9, 11]; | |
function numImpar(numbers) { | |
const numberSel = numbers.slice(0, 5); | |
const impar = numbers.filter((x) => x % 2 != 0); | |
for (var i = 0; i <= numbers.length; i++) { | |
return numberSel; | |
} | |
} | |
console.log(numImpar(numbers)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment