63 lines
No EOL
1.3 KiB
JavaScript
63 lines
No EOL
1.3 KiB
JavaScript
// Chipsregen
|
|
|
|
console.log ("Meine Seite läuft");
|
|
|
|
function createChip() {
|
|
|
|
const chip = document.createElement("img");
|
|
|
|
chip.src = "img/Chips.png";
|
|
|
|
chip.classList.add("chip");
|
|
|
|
chip.style.left = Math.random() * window.innerWidth + "px";
|
|
|
|
chip.style.animationDuration =
|
|
(Math.random() * 3 + 3) + "s";
|
|
|
|
chip.style.width =
|
|
(Math.random() * 50 + 50) + "px";
|
|
|
|
document.body.appendChild(chip);
|
|
|
|
setTimeout(() => {
|
|
chip.remove();
|
|
}, 6000);
|
|
}
|
|
|
|
setInterval(createChip, 300);
|
|
|
|
|
|
|
|
|
|
// Notenrechner
|
|
|
|
function berechneNote(punkte) {
|
|
if (punkte >= 90) {
|
|
return "sehr gut";
|
|
} else if (punkte >= 75) {
|
|
return "gut";
|
|
} else if (punkte >= 60) {
|
|
return "befriedigend";
|
|
} else if (punkte >= 50) {
|
|
return "ausreichend";
|
|
} else {
|
|
return "nicht bestanden";
|
|
}
|
|
}
|
|
|
|
function startNotenrechner() {
|
|
const punkte = Number(prompt("Wie viele Punkte hast du erreicht?"));
|
|
const max = Number(prompt("Maximale Punktzahl?"));
|
|
|
|
if (isNaN(punkte) || isNaN(max) || max === 0) {
|
|
alert("Bitte gültige Zahlen eingeben!");
|
|
return;
|
|
}
|
|
|
|
const prozent = Math.round((punkte / max) * 100);
|
|
const ergebnis = punkte + " von " + max + " Punkten (" + prozent + "%) = " + berechneNote(prozent);
|
|
|
|
console.log(ergebnis);
|
|
alert(ergebnis);
|
|
} |