{ question: «⚡ ¿Qué tipo de corriente promovió Tesla?», options: [«Corriente continua», «Corriente alterna», «Corriente pulsante», «Corriente alternante»], answer: 1 }, { question: «🌍 ¿Con qué importante sistema eléctrico trabajó Tesla?», options: [«Sistema de vapor», «Energía solar», «Sistema de corriente alterna», «Energía eólica»], answer: 2 }, { question: «📡 ¿Qué invento de Tesla se usa en la radiodifusión?», options: [«Microondas», «Transmisor de radio», «Televisión», «Drones»], answer: 1 }, { question: «🧪 ¿Qué experimento destacó Tesla en el desarrollo de energía inalámbrica?», options: [«Experimento del rayo», «Torre Wardenclyffe», «Radiotelescopio», «Energía solar»], answer: 1 }, { question: «🏭 ¿Qué empresa usó sus diseños eléctricos?», options: [«General Electric», «Tesla Motors», «Apple», «Ford»], answer: 0 }, { question: «🔋 ¿Qué concepto introdujo Tesla en la energía eléctrica?», options: [«Máquina de vapor», «Campo magnético rotatorio», «Energía cinética», «Circuito cerrado»], answer: 1 }, { question: «🔍 ¿Qué dispositivo inventó Tesla para detectar cambios en el campo eléctrico?», options: [«Multímetro», «Telemetría», «Osciloscopio», «Tesla coil»], answer: 3 }, { question: «⚙️ ¿En qué ferias mostró sus inventos?», options: [«Expo 2000», «Feria Mundial de Chicago», «Feria Internacional de Lima», «Feria de Nueva York»], answer: 1 }, { question: «🛰️ ¿Qué tecnología moderna se basa en sus ideas?», options: [«Automóviles eléctricos», «Energía solar», «Wi-Fi», «Robots autónomos»], answer: 2 } ]; let current = 0; let score = 0; let timer; let timeLeft = 15; function startTimer() { timeLeft = 15; document.getElementById(«quiz-timer»).innerText = timeLeft; clearInterval(timer); timer = setInterval(() => { timeLeft–; document.getElementById(«quiz-timer»).innerText = timeLeft; if (timeLeft === 0) { clearInterval(timer); disableOptions(); revealCorrect(); } }, 1000); } function renderQuestion() { const q = quizData[current]; const letters = [«A», «B», «C», «D»]; document.getElementById(«quiz-container»).className = «quiz-container»; document.getElementById(«quiz-container»).innerHTML = `
Pregunta ${current + 1} de ${quizData.length} ⏳ Tiempo: 15s
${q.question}
${q.options.map((opt, i) => ` `).join(«»)}
`; startTimer(); } window.selectAnswer = function(index) { clearInterval(timer); const correct = quizData[current].answer; const buttons = document.querySelectorAll(«.quiz-option-button»); buttons.forEach((btn, i) => { btn.disabled = true; if (i === correct) btn.classList.add(«correct»); if (i === index && index !== correct) btn.classList.add(«incorrect»); }); if (index === correct) score++; document.getElementById(«next-btn»).disabled = false; }; function disableOptions() { const buttons = document.querySelectorAll(«.quiz-option-button»); buttons.forEach(btn => btn.disabled = true); document.getElementById(«next-btn»).disabled = false; } function revealCorrect() { const correct = quizData[current].answer; const buttons = document.querySelectorAll(«.quiz-option-button»); buttons[correct].classList.add(«correct»); } window.nextQuestion = function() { current++; if (current < quizData.length) { renderQuestion(); } else { showResults(); } }; function showResults() { let message = ""; if (score === quizData.length) { message = "¡Increíble! Has respondido todo correctamente sobre Nikola Tesla. ⚡"; } else if (score >= quizData.length * 0.7) { message = «Buen trabajo, tienes un gran conocimiento sobre Tesla. 🧠»; } else if (score >= quizData.length * 0.4) { message = «Has hecho un buen esfuerzo, sigue aprendiendo sobre Tesla. 📚»; } else { message = «¡No te desanimes! Hay mucho más por descubrir sobre este gran inventor. 🌟»; } const shareText = `¡He acertado ${score} de ${quizData.length} preguntas sobre Nikola Tesla en un test! ¿Te atreves a superarme? responderapido.com`; document.getElementById(«quiz-container»).innerHTML = `
Has acertado ${score} de ${quizData.length} preguntas
${message}
`; } window.restartQuiz = function() { current = 0; score = 0; renderQuestion(); }; window.shareWhatsApp = function(text) { const url = `https://api.whatsapp.com/send?text=${text}`; window.open(url, ‘_blank’); }; renderQuestion(); })();