From bf06375ab8a29bbf00f0d0ae8dbefdc391147bca Mon Sep 17 00:00:00 2001 From: Geronimo Hidalgo <45217034@terciariourquiza.edu.ar> Date: Wed, 20 May 2026 18:15:15 -0300 Subject: [PATCH] feat: add function for numbers max,min and average --- ejercicios.js | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/ejercicios.js b/ejercicios.js index 567b4e4..949ca0d 100644 --- a/ejercicios.js +++ b/ejercicios.js @@ -56,3 +56,41 @@ function presentation(name,age){ } console.log(presentation(name,age)); + +// Septimo ejercicio + +const numbers = [ 1, 5, 10, 16, 32, 58] + +function numeroMaximo(array){ + let max = array[0]; + for(const num of array){ + if(num > max){ + max = num; + } + + } + return max; +} +console.log(`El valor maximo es ${numeroMaximo(numbers)}`); + +function numeroMinimo(array){ + let min = array[0]; + for(const num of array){ + if(num < min){ + min = num; + } + } + return min; +} +console.log(`El valor minimo es ${numeroMinimo(numbers)}`); + +function numeroPromedio(array){ + let sum = 0; + let cantidad = 0; + for(const num of array){ + sum+=num + cantidad++ + } + return (sum/cantidad) +} +console.log(`El promedio es ${numeroPromedio(numbers)}`); \ No newline at end of file