Compare commits
2 Commits
57ab13dc8d
...
81cd5f3fdf
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
81cd5f3fdf | ||
|
|
9427852793 |
BIN
img/hase.png
Normal file
BIN
img/hase.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.4 KiB |
38
script.js
38
script.js
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user