Joke Generator
<!DOCTYPE html>
<html>
<title>Generators</title>
<h1>Joke Generator</h1>
<button id="generateButton">Generate Joke</button>
<p id="jokeText"></p>
<script>
const jokes = [
"Why don't scientists trust atoms? Because they make up everything!",
"Did you hear about the mathematician who's afraid of negative numbers? He'll stop at nothing to avoid them!",
"Why don't skeletons fight each other? They don't have the guts!",
"What's the best thing about Switzerland? I don't know, but the flag is a big plus!",
"I'm reading a book about anti-gravity. It's impossible to put down!",
"Why did the scarecrow win an award? Because he was outstanding in his field!",
"Why did the tomato turn red? Because it saw the salad dressing!",
"What did one wall say to the other wall? I'll meet you at the corner!",
"Why don't vampires like garlic? It's a grave matter!",
"What do you call a bear with no teeth? A gummy bear!",
"Why don't skeletons fight each other? They don't have the guts!",
"My friend thinks he's so smart. He told me an onion is the only food that makes you cry. So, I threw a coconut at his face.",
"I used to be a baker, but I couldn't make enough dough. Now I'm a hitman. Kneading dough is a lot easier.",
"I asked the doctor if I could administer my own anesthesia before surgery. He said, 'Sure, knock yourself out!'",
"I have a fear of speed bumps, but I'm slowly getting over it.",
"I lost my job at the bank on my very first day. A woman asked me to check her balance, so I pushed her over.",
"They say love is like a battlefield. That explains why I'm sleeping alone in a trench.",
"I bought shoes from a drug dealer once. I don't know what he laced them with, but I've been tripping all day.",
"I was reading a horror story in Braille. Something bad is about to happen; I can feel it.",
"I used to hate facial hair, but then it grew on me."
];
function generateJoke() {
const randomIndex = Math.floor(Math.random() * jokes.length);
const joke = jokes[randomIndex];
const jokeText = document.getElementById("jokeText");
jokeText.textContent = joke;
}
const generateButton = document.getElementById("generateButton");
generateButton.addEventListener("click", generateJoke);
</script>
</body>
</html>