Build a Fortune Teller - Build a Fortune Teller

Tell us what’s happening:

It doesn’t satisfy test 9 :

9. The randomNumber should correspond to its fortune. For example, if randomNumber is 1, the selectedFortune should be equal to fortune1 and so on

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.";

const randomNumber = Math.floor(Math.random()*5)+ 1;
let selectedFortune;

if (randomNumber == 1) {
  let selectedFortune = fortune1;
} else if (randomNumber == 2) {
  let selectedFortune = fortune2;
} else if (randomNumber == 3) {
  let selectedFortune = fortune3;
} else if (randomNumber == 4) {
  let selectedFortune = fortune4;
} else if (randomNumber == 5) {
  let 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/147.0.0.0 Safari/537.36

Challenge Information:

Build a Fortune Teller - Build a Fortune Teller

GitHub Link: freeCodeCamp/curriculum/challenges/english/blocks/lab-fortune-teller/66c06d618d075c7f7f1b890a.md at main · freeCodeCamp/freeCodeCamp · GitHub

I think the problem is that you’re declaring selectedFortune multiple times inside the if blocks. You already declared it before the if statement. i hope it help.

Yes, it did. Thank you!