Build a Fortune Teller - Build a Fortune Teller

Tell us what’s happening:

Hi, I’m not really sure what I’m doing wrong, but it keeps telling me that I should initialize fortune1 with a string value. I think my code looks good just not sure why it’s deciding to act up. Any ideas??

Your code so far

const fortune1 = "Your cat will look very cuddly today.";
const fortune2 = "The weather will be nice tomorrow.";
const fortune3 = "Be cautious of your new neighbors.";
const fortune4 = "You will find a new hobby soon.";
const fortune5 = "It would be wise to avoid the color red today.";

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

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 if (randomNumber == 5) { console.log(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/146.0.0.0 Safari/537.36

Challenge Information:

Build a Fortune Teller - Build a Fortune Teller

Hi @KGKhxh72 ,

You should create a selectedFortune variable and assign the appropriate fortune

Are you meeting this requirement in the user stories?

Aren’t you seeing this syntax error in the console?

SyntaxError: unknown: Unexpected token, expected "," (11:37)

   9 |
  10 | if (randomNumber == 1) { console.log(fortune1);}
> 11 | else if (randomNumber == 2( { console.log(fortune2);}
     |                                      ^
  12 | else if (randomNumber == 3) { console.log(fortune3);}
  13 | else if (randomNumber == 4) { console.log(fortune4);}
  14 | else if (randomNumber == 5) { console.log(fortune5);}

Happy coding!

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