Build a Fortune Teller - Build a Fortune Teller

Tell us what’s happening:

  1. I’ve generated a random number between 1 and 5 and I assigned to the randomNumber variable, I don’t know what I did wrong?
  2. My randomNumber variable corresponds with fortune variables?

Your code so far

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;

if (randomNumber === 1) {
  selectedFortune = fortune1;
}else if (randomNumber === 2) {
  selectedFortune = fortune2;
}else if (randomNumber = 3) {
  selectedFortune = fortune3;
}else if (randomNmber = 4) {
  selectedFortune = fortune4;
}else if (randomNumber = 5) {
  selectedFortune = fortune5;
}
console.log(selectedFortune);


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36

Challenge Information:

Build a Fortune Teller - Build a Fortune Teller

Welcome back @malvo !

You have a typo. You are also using an assignment operator (=) rather than an equality operator (===) in some of your expressions.

Happy coding!

Thank you! The typo and the assignment operator were the problem. Thank you, @dhess .

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.