"Creating a Fortune Teller with JavaScript"

Today’s Tiny JavaScript Project I wrote a simple “Fortune Teller” script in JavaScript — it picks a random fortune each time you run it! let fortune1 = "Your cat will look very cuddly today."; let fortune2 = "The weather will be nice tomorrow."; let fortune3 = "Be cautious of your new neighbors."; let fortune4 = "You will find a new hobby soon."; let fortune5 = "It would be wise to avoid the color red today."; let randomNumber = Math.floor(Math.random() * 5) + 1; let selectedFortune = randomNumber; if (randomNumber === 1) selectedFortune = fortune1; else if (randomNumber === 2) selectedFortune = fortune2; else if (randomNumber === 3) selectedFortune = fortune3; else if (randomNumber === 4) selectedFortune = fortune4; else if (randomNumber === 5) selectedFortune = fortune5; console.log(selectedFortune); 🧠 It’s a small project, but a fun way to practice: Random number generation Conditional logic Console output What fortune did you get when you ran it? 👀 #JavaScript #Coding #WebDevelopment #100DaysOfCode #LearnToCode

To view or add a comment, sign in

Explore content categories