diff --git a/ejercicios.js b/ejercicios.js index 8e69ac3..77b24ff 100644 --- a/ejercicios.js +++ b/ejercicios.js @@ -3,3 +3,32 @@ console.log("Archivo vinculado exitosamente"); // Resolver acá los ejercicios propuestos. +const numeros = [1, 5, 3, 8, 15, 2, 7]; +const obtenerMaximo = (array) => { + let max = array[0]; + for (const num of array) { + if (num > max) { + max = num; + } + } + return max; +}; +const obtenerMinimo = (array) => { + let min = array[0]; + for (const num of array) { + if (num < min) { + min = num; + } + } + return min; +}; +const obtenerPromedio = (array) => { + let suma = 0; + for (const num of array) { + suma = suma + num; + } + return suma / array.length; +}; +console.log("Valor máximo:", obtenerMaximo(numeros)); +console.log("Valor mínimo:", obtenerMinimo(numeros)); +console.log("Promedio:", obtenerPromedio(numeros)); \ No newline at end of file diff --git a/index.html b/index.html index b1c7d4f..c7161f8 100644 --- a/index.html +++ b/index.html @@ -9,7 +9,6 @@

Primeros ejercicios en javascript

Vincular el archivo ejercicios.js a este archivo. Luego, resolver ahí los ejercicios.

- - +