forked from marquez.juan/javascript-primeros-ejercicios
Compare commits
2 Commits
4ee8c6f38d
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d146cb6edc | ||
|
|
5198986ce3 |
@@ -36,7 +36,50 @@ for (let m=0; m < maximo; m = m+3){
|
||||
//ejercicio 6
|
||||
let frutas = ["kiwi", "mango","banana"];
|
||||
for (let fruta of frutas){
|
||||
console.log(fruta)
|
||||
console.log(fruta);
|
||||
}
|
||||
|
||||
//ejercicio 7
|
||||
function presentarse (nombre, edad) {
|
||||
return`soy ${nombre} y tengo ${edad}`;
|
||||
}
|
||||
console.log(presentarse("romeo", 26));
|
||||
|
||||
//ejercicio 8
|
||||
let numeritos = [ 1, 3, 8, 2, 18, 6 ];
|
||||
|
||||
//valor maximo
|
||||
function buscarmax(lista){
|
||||
let max = lista[0];
|
||||
for(let indice=1; indice<lista.length; indice++ ){
|
||||
if(lista[indice]>max){
|
||||
max = lista[indice];
|
||||
}
|
||||
}
|
||||
return max;
|
||||
}
|
||||
console.log(buscarmax(numeritos));
|
||||
|
||||
//valor minimo
|
||||
function buscarmin(lista){
|
||||
let min = lista[0];
|
||||
for(let indice=1; indice<lista.length; indice++ ){
|
||||
if(lista[indice]<min){
|
||||
min = lista[indice];
|
||||
}
|
||||
}
|
||||
return min;
|
||||
}
|
||||
console.log(buscarmin(numeritos));
|
||||
|
||||
//valor promedio
|
||||
function promediolista (lista){
|
||||
let sumatoria = 0;
|
||||
for (indice=0; indice<lista.length; indice++){
|
||||
sumatoria += lista[indice]
|
||||
}
|
||||
return sumatoria/lista.length;
|
||||
}
|
||||
console.log(promediolista(numeritos));
|
||||
|
||||
// Resolver acá los ejercicios propuestos.
|
||||
Reference in New Issue
Block a user