- The randomNumber should correspond to its fortune. For example, if randomNumber is 1, the selectedFortune should be equal to fortune1 and so on.
This is really confusing me, I didnt know how to do so i looked on w3 and this what i came up with, its so wrong it throws errors on lines that have previously passed
if someone could explain how to would be great
Your code so far
//1-5-pass
const fortune1 = "Your cat will look very cuddly today.";
const fortune2 = "The weather will be nice tomorrow.";
const fortune3 = "Be cautious of your new neighbours.";
const fortune4 = "You will find a new hobby soon.";
const fortune5 = "It would be wise to avoid the color red today.";
//6-7pass
let randomNumber = Math.floor(Math.random() * 5) + 1;
console.log(randomNumber);
//8-pass
let selectedFortune = 'randomNumber';
//9-
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/134.0.0.0 Safari/537.36
Challenge Information:
Build a Fortune Teller - Build a Fortune Teller