diff --git a/ejercicios.js b/ejercicios.js index 8e69ac3..949ca0d 100644 --- a/ejercicios.js +++ b/ejercicios.js @@ -3,3 +3,94 @@ console.log("Archivo vinculado exitosamente"); // Resolver acá los ejercicios propuestos. + +// Primer ejercicio + +const name = "Geronimo" +const age = 22 + +if (age >= 18) { + console.log(name +" es mayor de edad"); +} else { + console.log(name +" es menor de edad"); +} + +// Segundo ejercicio + +if (age <13 ) { + console.log(name +" es un infante"); +} else if (age >=18 ) { + console.log(name +" es un adulto"); +} else { + console.log(name +" es un adolescente"); +} + +// Tercer ejercicio + +let n=3 +const maximo=30 + +while (n < maximo) { + console.log(n) + n+=3 +} + +// Cuarto ejercicio + +for (let i=3; i < maximo; i+=3){ + console.log(i) +} + +// Quinto ejercico + +const frutas=["manzana","kiwi","frutilla"] +for (const fruta of frutas){ + console.log(fruta); +} + +// Sexto ejercicio + +function presentation(name,age){ + const p = `Hola mi nombre es ${name} y mi edad es ${age}`; + return p +} + +console.log(presentation(name,age)); + +// Septimo ejercicio + +const numbers = [ 1, 5, 10, 16, 32, 58] + +function numeroMaximo(array){ + let max = array[0]; + for(const num of array){ + if(num > max){ + max = num; + } + + } + return max; +} +console.log(`El valor maximo es ${numeroMaximo(numbers)}`); + +function numeroMinimo(array){ + let min = array[0]; + for(const num of array){ + if(num < min){ + min = num; + } + } + return min; +} +console.log(`El valor minimo es ${numeroMinimo(numbers)}`); + +function numeroPromedio(array){ + let sum = 0; + let cantidad = 0; + for(const num of array){ + sum+=num + cantidad++ + } + return (sum/cantidad) +} +console.log(`El promedio es ${numeroPromedio(numbers)}`); \ No newline at end of file diff --git a/index.html b/index.html index b1c7d4f..c766e14 100644 --- a/index.html +++ b/index.html @@ -12,4 +12,5 @@ +