Javascript #8

Open
gaibazzi.lucio wants to merge 8 commits from gaibazzi.lucio/javascript-primeros-ejercicios:main into main
Showing only changes of commit 5c200b3719 - Show all commits

View File

@@ -39,4 +39,53 @@ function presentarse(nombre, edad) {
return `Me llamo ${nombre} y tengo ${edad} años`;
}
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));