forked from marquez.juan/javascript-primeros-ejercicios
Compare commits
8 Commits
809d1538e5
...
bf06375ab8
| Author | SHA1 | Date | |
|---|---|---|---|
| bf06375ab8 | |||
| 5a97198912 | |||
| 03a14f21b2 | |||
| 9de15985f4 | |||
| cc4c171446 | |||
| a181ee8682 | |||
| 1815a90c34 | |||
| 44327abb64 |
@@ -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)}`);
|
||||
@@ -12,4 +12,5 @@
|
||||
|
||||
|
||||
</body>
|
||||
<script src="ejercicios.js"></script>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user