Realizo el ejercicio 8 de la clase 6

This commit is contained in:
Lucio Gaibazzi
2026-05-04 18:30:30 -03:00
parent dc1e232e6b
commit 5c200b3719

View File

@@ -40,3 +40,52 @@ function presentarse(nombre, edad) {
} }
console.log(presentarse("Lucho", 21)); console.log(presentarse("Lucho", 21));
const numeros = [1, 3, 8, 2, 18, 6]
function valormaximo(valormax) {
let max = valormax[0];
for (const num of valormax) {
if (num > max) {
max = num;
}
}
return max;
}
console.log("Máximo:", valormaximo(numeros));
function valorminimo(valormin) {
let min = valormin[0];
for (const num of valormin) {
if (num < min) {
min = num;
}
}
return min;
}
console.log("Mínimo:", valorminimo(numeros));
function valorpromedio(promedio) {
let suma = 0;
let contador = 0;
for (const num of promedio) {
suma = (suma + num);
contador = (contador + 1);
}
return suma / contador;
}
console.log("Promedio:", valorpromedio(numeros));