Converting switch to If...else


I created this block of code for the Magic Eight Ball project I used a switch statement instead of If…else…if.

const randomNumber = Math.floor(Math.random() * 8);
let eightBall = ‘’;

switch (randomNumber) {
case 0:
eightBall = ‘It is certain’;
case 1:
eightBall = ‘It is decidedly so’;
case 3:
eightBall = ‘Reply hazy try again’;
case 4:
eightBall = ‘Cannot predict now’;
case 5:
eightBall = ‘Do not count on it’;
case 6:
eightBall= ‘My sources say no’;
case 7:
eightBall = ‘Outlook not so good’;
case 8:
eightBall = ‘Signs point to yes’;
console.log(Magic Eight Ball says ${eightBall});

The instruction suggest that I should convert the switch to an if…else…if statement. I have tried a couple of ways but I keep getting a syntax error and I’m not sure what I’m doing wrong.

What I can’t figure out is how to use both variables in the if statement. I would appreciate if someone could show me how to write the statement.


Think of each case as an if conditional.