From f925c4c8d66561c8364f677f578fd47185c6343a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mariana=20Gallardo=20Garc=C3=ADa?= <98504666+marianagaga30@users.noreply.github.com> Date: Tue, 8 Feb 2022 21:42:09 -0600 Subject: [PATCH 1/2] Resolucion ejercicios Js --- script.js | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/script.js b/script.js index c4df4a3..f558eb1 100644 --- a/script.js +++ b/script.js @@ -2,6 +2,30 @@ const ejercicio1 = [ 3, 100, 85, 64, 46, 39, 40, 30, 20, 24, 25, 6, 10, 54, 82, 71, 67, 77, 17, 29, 19, 88, 456, 13, 23, 24, ]; +//Resolucion +function primo (a) { + if (a <= 1) { + return false + } else { + for (let i = 2; i < a; i ++){ + if (a % i == 0){ + return false + } + } + return true + } +} + +function numeroPrimo() { + ejercicio1.forEach(function numeroPrimo(a) { + if (primo(a)) { + console.log ("El nĂºmero " + a + " es primo") + } + }) +} + +numeroPrimo(); + const ejercicio2 = [ { @@ -35,3 +59,30 @@ const ejercicio2 = [ esFamiliar: true, }, ]; +//Resolucion +let invitados = [] + +for (let i = 0; i < ejercicio2.length; i++) { + if (ejercicio2[i].edad >= 18 && ejercicio2[i].esFamiliar) { + console.log(ejercicio2[i].nombre + " bienvenido a la fiesta") + } +} + + +//Resolucion Ejercicio 3: + + + +console.log(`ejercicio 3`); +let x = 0; +let y = 1; +let z = 0; + +for (let fibo = 0; fibo <= 50; fibo ++) { + + z = x + y; + console.log(z); + x = y; + y = z; +} + From 164383781e47047f5d67c14caadf6dca69597110 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mariana=20Gallardo=20Garc=C3=ADa?= <98504666+marianagaga30@users.noreply.github.com> Date: Thu, 24 Feb 2022 10:49:46 -0600 Subject: [PATCH 2/2] Edit2 --- script.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/script.js b/script.js index f558eb1..037d2ff 100644 --- a/script.js +++ b/script.js @@ -2,7 +2,7 @@ const ejercicio1 = [ 3, 100, 85, 64, 46, 39, 40, 30, 20, 24, 25, 6, 10, 54, 82, 71, 67, 77, 17, 29, 19, 88, 456, 13, 23, 24, ]; -//Resolucion +//Resolucion Ej1 function primo (a) { if (a <= 1) { return false @@ -59,7 +59,7 @@ const ejercicio2 = [ esFamiliar: true, }, ]; -//Resolucion +//Resolucion Ej2 let invitados = [] for (let i = 0; i < ejercicio2.length; i++) {