Build a Fortune Teller - Build a Fortune Teller

Tell us what’s happening:

I am getting an output, but still receiving this error. What am I doing wrong?

  1. The randomNumber should correspond to its fortune. For example, if randomNumber is 1, the selectedFortune should be equal to fortune1 and so on.
    // tests completed
    // console output
    You will find a $20 bill inside your breakfast burrito.
    3

Your code so far

let fortune1 = "Your cat will look like Winston Churchill.";
let fortune2 = "You will be abducted by aliens.";
let fortune3 = "You will find a $20 bill inside your breakfast burrito.";
let fortune4 = "Someone will steal all of your car tires.";
let fortune5 = "You will never come to this fortune teller again.";
let randomNumber = Math.floor(Math.random() * 5) + 1;
let selectedFortune = randomNumber;
if (randomNumber == 1) {
  console.log(fortune1);
} else if (randomNumber == 2) {
  console.log(fortune2);
} else if (randomNumber == 3) {
  console.log(fortune3);
} else if (randomNumber == 4) {
  console.log(fortune4);
} else {
  console.log(fortune5);
}
console.log(selectedFortune);

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36

Challenge Information:

Build a Fortune Teller - Build a Fortune Teller

You should create a selectedFortune variable and assign the appropriate fortune

Where are you assigning to the selectedFortune variable? Is that assignment per the given rules?

Welcome to the forum :wave:

Read the instruction again, carefully.

if randomNumber is 1, the selectedFortune should be equal to fortune1 and so on.

And see what selectedFortune is equal to:

A bit of a mis-match here. You can see there’s something amiss because you never really use selectedFortune in your code and it always just holds the same value as randomNumber which is a bit redundant.