Build a Fortune Teller - Build a Fortune Teller

Tell us what’s happening:

Hello
I am stuck
The results won’t go through
Could someone help and explain please

Your code so far

const fortune1 = "Drink some water";
const fortune2 = "Relax and breathe";
const fortune3 = "Eat with your fingers";
const fortune4 = "Smile all day long";
const fortune5 = "Have a break";

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

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

Challenge Information:

Build a Fortune Teller - Build a Fortune Teller

You appear to have some syntax errors.

Can you see error messages in your console?

What have you done to try to address these?

Please don’t open duplicate topics for the same challenge as it’s against the rules. You can reply to this post if you still need help on this challenge. I will delete your duplicate post.

You have two issues with your code.

Firstly the else statement should not be followed by a conditional clause. When you have a series of if … else if statements, the final else statement is designed to cover all other cases not covered by the previous conditions. If you wish to include a condition, it should be an else if statement. (It’s not imperative to include an else statement at all, if you don’t need to).

Secondly, you have a variable in your code which you haven’t declared properly.