Compare commits

...

2 Commits

Author SHA1 Message Date
Omar taky
81cd5f3fdf hase img lagen 2025-12-03 10:20:52 +01:00
Omar taky
9427852793 js Weitermachen 2025-12-03 10:16:12 +01:00
2 changed files with 38 additions and 0 deletions

BIN
img/hase.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

View File

@@ -17,3 +17,41 @@ console.log("Hasen-Paare pro Monat:");
hasenPaare.forEach((paare, index) => {
console.log(`Monat ${index + 1}: ${paare} Paar(e)`);
});
let aktuellerMonat = 1;
function zeigeMonat() {
document.getElementById("monat").textContent = aktuellerMonat;
}
function zeigeHasen() {
const container = document.getElementById("hasenContainer");
container.innerHTML = "";
const anzahlPaare = hasenPaare[aktuellerMonat - 1];
for (let i = 0; i < anzahlPaare; i++) {
const hase = document.createElement("img");
hase.src = "img/hase.png";
hase.alt = "Hasen-Paar";
hase.classList.add("hase");
container.appendChild(hase);
}
}
function naechsterMonat() {
if (aktuellerMonat < monate) {
aktuellerMonat++;
zeigeMonat();
zeigeHasen();
} else {
alert("Maximale Anzahl an Monaten erreicht!");
}
}
document.getElementById("nextMonthBtn").addEventListener("click", naechsterMonat);
zeigeMonat();
zeigeHasen();