Build a Fortune Teller - Build a Fortune Teller

Tell us what’s happening:

I am getting a syntax error for the Build a Fortune Teller exercise.

My syntax error says “You should initialize fortune1 with a string value”. If I remove the IF statement then I don’t get an error.

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 neighbours.";
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
  } elseif (randomNumber == 2) {
    selectedFortune = fortune2
  } elseif (randomNumber == 3) {
    selectedFortune = fortune3
  } elseif (randomNumber == 4) {
    selectedFortune = fortune4
  } elseif (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/148.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

Hi there,

JavaScript doesn’t have a elseif like Python’s elif. Instead the syntax is else if. Fix that and the tests should pass.

Happy coding!

you have an additional synax issue here, the last block is unclosed

Thanks very much, I spent ages looking at it and just couldn’t see it!