Skip to content

Instantly share code, notes, and snippets.

@sauerlock
Created October 25, 2022 14:25
Show Gist options
  • Save sauerlock/149ad93ea20b2e6f2b9cf368a8d3870c to your computer and use it in GitHub Desktop.
Save sauerlock/149ad93ea20b2e6f2b9cf368a8d3870c to your computer and use it in GitHub Desktop.
Exercicio 4 - Arrays
// 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