bruno-js #5

Open
tocaymasa.bruno wants to merge 8 commits from tocaymasa.bruno/javascript-primeros-ejercicios:bruno-js into main
Showing only changes of commit cac83e42b0 - Show all commits

View File

@@ -45,6 +45,7 @@ function presentarse(nombre, edad) {
console.log(presentarse(nombre, edad));
const numeros = [1, 3, 8, 2, 18, 6];
function Vmaximo(numeros) {
let max = -1;
for (const n of numeros) {
@@ -53,5 +54,26 @@ function Vmaximo(numeros) {
}
}
return max;
}
console.log(Vmaximo(numeros))
function Vminimo(numeros) {
let min = 1000;
for (const n of numeros) {
if (min > n) {
min = n;
}
}
return min;
}
console.log(Vminimo(numeros))
function promedio(numeros) {
let suma = 0;
for (const n of numeros) {
suma = suma + n;
}
let resultado = suma / numeros.length;
return resultado;
}
console.log(promedio(numeros))