Build a Fortune Teller - Build a Fortune Teller

Tell us what’s happening:

Please help me with this step. I can’t figureout how to resolve the problem:

  1. The randomNumber should correspond to its fortune. For example, if randomNumber is 1, the selectedFortune should be equal to fortune1 and so on.

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 neighbors.";
let fortune4 = "You will find a new hobby soon.";
let fortune5 = "You will find a new hobby soon.";

let max = 5;
let min = 1;

let randomNumber = Math.round(Math.random() * (max - min)) +1;
console.log(randomNumber);

let selectedFortune;

const fortunTeller = (randomNumber) => {
  
  if (randomNumber === 1) {
    selectedFortune = fortune1;
    console.log("Your cat will look very cuddly today.");
   } else if (randomNumber === 2) {
     selectedFortune = fortune2;
     console.log(selectedFortune);
   } else if (randomNumber === 3) {
     selectedFortune = fortune3;
     console.log(selectedFortune);
   } else if (randomNumber === 4) {
     selectedFortune = fortune4;
     console.log(selectedFortune);
   } else if (randomNumber === 5){
     selectedFortune = fortune5;
   } else {
     return;
   }

  }

  

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36

Challenge Information:

Build a Fortune Teller - Build a Fortune Teller

Hi. The instructions don’t ask you to create a function so just do an if statement after your selected Fortune Variable.

Think how you can adjust so that selectedFortune is correctly logged to the console. Look at user story 3 and see what it is doing.

Have a look again at your formula to select a random number between 1 and 5 (your randomNumber variable).

1 Like

Thank you for your guidance.

1 Like