Last active
October 25, 2022 14:24
-
-
Save sauerlock/823b81c3ea5f2225ab0b66e0044e3110 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
Exercicio 4 - Arrays | |
-------------------- | |
A [Pen](https://codepen.io/sauerlock/pen/MWXWOmb) by [sauerlock](https://codepen.io/sauerlock) on [CodePen](https://codepen.io). | |
[License](https://codepen.io/license/pen/MWXWOmb). |
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