mirror of
https://github.com/CristianCruz0309/proyectos-curso-javascript.git
synced 2026-08-15 02:50:10 +00:00
Proyectos (DIA 1 - 13)
Realizados gracias al curso "JAVASCRIPT TOTAL"
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
let array = [1.7, 3, 2.5, 4.8, 3.6];
|
||||
|
||||
function listarNotas() {
|
||||
let lista = document.getElementById("listaNotas");
|
||||
lista.innerHTML = ""; // limpia la lista
|
||||
|
||||
for (let nota of array) {
|
||||
let item = document.createElement("li");
|
||||
item.innerText = nota;
|
||||
|
||||
if (nota < 3.0) {
|
||||
item.classList.add("nota-mala");
|
||||
} else {
|
||||
item.classList.add("nota-buena");
|
||||
}
|
||||
|
||||
lista.appendChild(item);
|
||||
}
|
||||
}
|
||||
|
||||
function calcularPromedio() {
|
||||
let suma = 0;
|
||||
|
||||
for (i=0; i < 5; i++) {
|
||||
suma += array[i];
|
||||
}
|
||||
|
||||
let promedio = (suma / 5);
|
||||
document.getElementById("promedio").textContent = promedio
|
||||
}
|
||||
|
||||
function notaMasAlta() {
|
||||
let notaAlta = 0;
|
||||
let i = 0;
|
||||
while (i < 5) {
|
||||
if (array[i] > notaAlta) {
|
||||
notaAlta = array[i]
|
||||
}
|
||||
i++;
|
||||
}
|
||||
document.getElementById("nota").textContent = notaAlta
|
||||
}
|
||||
|
||||
function hayAplazo() {
|
||||
let aplazo = "No";
|
||||
let i = 0;
|
||||
|
||||
do {
|
||||
if (array[i] < 3) {
|
||||
aplazo = "Sí";
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
} while (i < 5);
|
||||
document.getElementById("aplazo").textContent = aplazo;
|
||||
}
|
||||
Reference in New Issue
Block a user