From d9293fa3c504657019b775fc568ec9e0764dd2a2 Mon Sep 17 00:00:00 2001 From: Valenti Taiel <45264983@terciariourquiza.edu.ar> Date: Thu, 14 May 2026 15:16:01 -0300 Subject: [PATCH] resolucion ultimo ejercicio --- ejercicios.js | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/ejercicios.js b/ejercicios.js index d90bf5e..a58b511 100644 --- a/ejercicios.js +++ b/ejercicios.js @@ -43,4 +43,37 @@ for (const fruta of frutas){ function presentarse(nombre, edad){ return `Me llamo ${nombre} y tengo ${edad} años.`; } -console.log(presentarse("Taiel", 22)); \ No newline at end of file +console.log(presentarse("Taiel", 22)); +//Séptimo Ejercicio +const numeros = [1, 3, 8, 2, 18, 6, 13, 50, 22]; +function encontrarMayor(lista){ + let mayor = lista[0]; + for (const numero of lista){ + if (numero > mayor){ + mayor = numero; + } + } + return mayor; +} +console.log(encontrarMayor(numeros)); + +function encontrarMenor(lista){ + let menor = lista [0]; + for (const numero of lista){ + if (numero < menor){ + menor = numero; + } + } + return menor; +} +console.log(encontrarMenor(numeros)); + +function calcularPromedio(lista){ + let sumaTotal = 0; + for (const numero of lista){ + sumaTotal += numero; + } + let promedio = sumaTotal / lista.length; + return promedio; +} +console.log(calcularPromedio(numeros)); \ No newline at end of file