main #12

Open
ojeda.alexis wants to merge 6 commits from ojeda.alexis/javascript-primeros-ejercicios:main into main
Showing only changes of commit e82a87fa0a - Show all commits

View File

@@ -12,6 +12,8 @@ if (edad >= 18) {
} else {
console.log(`Hola, ${nombre}!, usted es menor de edad.`);
}
console.log("Ejercicio 3: Etapas de la vida");
if (edad > 18) {
console.log(`Hola, ${nombre}!, usted esta en su adultez.`);
@@ -21,14 +23,18 @@ if (edad > 18) {
console.log(`Hola, ${nombre}!, usted esta en su infancia.`);
}
let maximo = 0;
console.log("Ejercicio 4: Multiplos de 3 bucle while");
while (maximo < 15) {
console.log(maximo);
maximo = maximo + 3;
const maximo = 15;
let multiplos = 0
while (multiplos < maximo) {
console.log(multiplos);
multiplos = multiplos + 3;
}
console.log("Ejercicio 5: Multiplos de 3 bucle for");
for (let maximo2 = 0; maximo2 < 15; maximo2 = maximo2 + 3) {
for (let maximo2 = 0; maximo2 < maximo; maximo2 = maximo2 + 3) {
console.log(maximo2);
}
@@ -40,8 +46,8 @@ for (const fruta of frutas) {
console.log("Ejercicio 7: Funcion saludar");
function presentarse(nomre, edad) {
return `Hola, me llamo ${nombre} Tego ${edad} años.`;
function presentarse(nombre, edad) {
return `Hola, me llamo ${nombre} Tengo ${edad} años.`;
}
console.log(presentarse(nombre, edad));
@@ -58,4 +64,28 @@ function numeroMaximo(numeros) {
}
return max;
}
console.log(numeroMaximo(numeros));
console.log(numeroMaximo(numeros));
function numeroMinimo(numeros) {
let min = numeros[0];
for (let i = 1; i > numeros.length; i++) {
if (numeros[i] < min) {
min = numeros[i];
}
}
return min;
}
console.log(numeroMinimo(numeros));
function promediar(numeros) {
let suma = 0;
for (let i = 0; i < numeros.length; i++) {
suma = numeros[i] + suma;
}
return suma / numeros.length;
}
console.log(promediar(numeros));