quacky-duck-world / script.js
victor's picture
victor HF Staff
a duck
4b9d0c6 verified
raw
history blame contribute delete
783 Bytes
document.addEventListener('DOMContentLoaded', () => {
// Random duck fact generator
const duckFacts = [
"Ducks have three eyelids!",
"A duck's feathers are waterproof.",
"Ducks can sleep with one eye open.",
"Baby ducks can swim immediately after hatching.",
"Some ducks can dive up to 40 feet underwater."
];
const randomFact = duckFacts[Math.floor(Math.random() * duckFacts.length)];
console.log(`Did you know? ${randomFact}`);
});
// Simple duck click handler
document.querySelectorAll('.duck-interactive').forEach(duck => {
duck.addEventListener('click', () => {
duck.classList.add('animate-ping');
setTimeout(() => {
duck.classList.remove('animate-ping');
}, 500);
});
});