333

import React, { useState } from „react“; import { motion } from „framer-motion“; import { Button } from „@/components/ui/button“; import { Card, CardContent } from „@/components/ui/card“; const levels = [ { question: „Welches Tier kann schwimmen?“, options: [„Affe“, „Fisch“, „Elefant“, „Schlange“], answer: „Fisch“, }, { question: „Was wächst auf Bäumen?“, options: [„Äpfel“, „Autos“, „Socken“, „Bücher“], answer: „Äpfel“, }, { question: „Welches Tier ist nachtaktiv?“, options: [„Eule“, „Affe“, „Hase“, „Frosch“], answer: „Eule“, }, { question: „Was isst ein Affe gern?“, options: [„Pizza“, „Banane“, „Schokolade“, „Käse“], answer: „Banane“, }, ]; export default function JungleQuiz() { const [level, setLevel] = useState(0); const [isCorrect, setIsCorrect] = useState(null); const handleAnswer = (option) => { if (option === levels[level].answer) { setIsCorrect(true); setTimeout(() => { if (level < levels.length - 1) { setLevel(level + 1); setIsCorrect(null); } else { alert("Coco hat alle Bananen gefunden! 🎉"); } }, 1000); } else { setIsCorrect(false); } }; return (
🦧

{levels[level].question}

{levels[level].options.map((option) => ( ))}
{isCorrect === false &&

Oops! Probier’s noch mal!

}
); }