Compare commits
7 Commits
main
...
ca08aa2bfd
| Author | SHA1 | Date | |
|---|---|---|---|
| ca08aa2bfd | |||
| c4a912038f | |||
| cceabb547f | |||
| 571518de42 | |||
| 14691f2714 | |||
| 5facba6d68 | |||
| 29fba37097 |
@@ -3,3 +3,32 @@
|
||||
console.log("Archivo vinculado exitosamente");
|
||||
|
||||
// Resolver acá los ejercicios propuestos.
|
||||
const numeros = [1, 5, 3, 8, 15, 2, 7];
|
||||
const obtenerMaximo = (array) => {
|
||||
let max = array[0];
|
||||
for (const num of array) {
|
||||
if (num > max) {
|
||||
max = num;
|
||||
}
|
||||
}
|
||||
return max;
|
||||
};
|
||||
const obtenerMinimo = (array) => {
|
||||
let min = array[0];
|
||||
for (const num of array) {
|
||||
if (num < min) {
|
||||
min = num;
|
||||
}
|
||||
}
|
||||
return min;
|
||||
};
|
||||
const obtenerPromedio = (array) => {
|
||||
let suma = 0;
|
||||
for (const num of array) {
|
||||
suma = suma + num;
|
||||
}
|
||||
return suma / array.length;
|
||||
};
|
||||
console.log("Valor máximo:", obtenerMaximo(numeros));
|
||||
console.log("Valor mínimo:", obtenerMinimo(numeros));
|
||||
console.log("Promedio:", obtenerPromedio(numeros));
|
||||
@@ -9,7 +9,6 @@
|
||||
<h1>Primeros ejercicios en javascript</h1>
|
||||
<p>Vincular el archivo ejercicios.js a este archivo. Luego, resolver ahí
|
||||
los ejercicios.</p>
|
||||
|
||||
|
||||
<script src="ejercicios.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user