Tell us what’s happening:
I have completed all the requirement for this lab but its still telling me that i need to use Math.random() to generate a random number and that it should correspond to its fortune. That’s exaclty what I did so im confused and use the if else statements to check if the randomNumber matches the appropriate value and assigned the fortune to selectedFortune if true. So I’m not sure what im doing wrong.
Your code so far
let fortune1 = "Your car 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(1, 2, 3, 4, 5) * (5 -1) + 1);
if(randomNumber === 1) {
let selectedFortune = fortune1;
console.log(selectedFortune);
} else if(randomNumber === 2){
let selectedFortune = fortune2;
console.log(selectedFortune);
} else if(randomNumber === 3) {
let selectedFortune = fortune3;
console.log(selectedFortune);
} else if(randomNumber === 4) {
let selectedFortune = fortune4;
console.log(selectedFortune);
} 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/143.0.0.0 Safari/537.36
Challenge Information:
Build a Fortune Teller - Build a Fortune Teller