From cbf9cbc748e711c61f672b2c19f1d6aa41e9d125 Mon Sep 17 00:00:00 2001 From: jonathanrchamorro <68171390+jonathanrchamorro@users.noreply.github.com> Date: Sun, 30 Aug 2020 15:23:38 -0500 Subject: [PATCH] creo el ejercicio filtrar numeros pares en un arreglio --- src/index.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/index.js b/src/index.js index 682728d..0d6a455 100644 --- a/src/index.js +++ b/src/index.js @@ -1,5 +1,15 @@ -const getEvenNumbers = (numbersArray) => { - // your code -} -module.exports = getEvenNumbers; \ No newline at end of file +// EJEMPLO DE GUIA PARA EL RETO +// const getEvenNumbers = (numbersArray) => { +// // your code +// } + +// module.exports = getEvenNumbers; + +// Defino el arreglo de numeros +let arreglo = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]; +// defino otro arreglo que contendra los numeros pares y le paso la funcion.filter +let numerosPares = arreglo.filter(function(numero){ + return numero%2 ==0; // divido el numero en 2 si el resultado = 0 indica que es par +}); +console.log ('los numeros pares en el arreglo son ' + numerosPares); // imprimo los numeros pares \ No newline at end of file