Grundgerüst

This commit is contained in:
2025-11-26 14:11:06 +01:00
commit 9e9bf2ec5e
3 changed files with 164 additions and 0 deletions

58
script.js Normal file
View File

@@ -0,0 +1,58 @@
let currentMonth = 1;
function getFibonacci(n) {
if (n <= 2) return 1;
let a = 1, b = 1;
for (let i = 3; i <= n; i++) {
let next = a + b;
a = b;
b = next;
}
return b;
}
function showMonth(month) {
document.getElementById("monthDisplay").textContent = "Monat: " + month;
}
function clearRabbits() {
document.getElementById("rabbitContainer").innerHTML = "";
}
function createRabbitPair() {
const pair = document.createElement("div");
pair.classList.add("rabbit");
pair.textContent = "🐇🐇";
return pair;
}
function showRabbits(count) {
clearRabbits();
const container = document.getElementById("rabbitContainer");
for (let i = 0; i < count; i++) {
container.appendChild(createRabbitPair());
}
}
function nextMonth() {
currentMonth++;
showMonth(currentMonth);
const rabbitCount = getFibonacci(currentMonth);
showRabbits(rabbitCount);
}
document.getElementById("nextMonthButton")
.addEventListener("click", nextMonth);