Magic 8 b

whenever I did my switch statement I tried to set each case equal to a string but it did not work. I had to create a console.log for each statement. Does anyone know why that is?

Please post the code you are having trouble with so others can review and comment.

I redid it a second time and it worked!

let userName = “Scott”;

userName ? console.log(Hello ${userName}) : console.log(“Hello!”);

let userQuestion = “Are puppies cute?”;

console.log(${userName} has asked ${userQuestion});

let randomNumber = Math.floor(Math.random() * 8);

console.log(randomNumber);

let eightBall = ‘’;

switch(randomNumber) {
case 0:
eightBall = ‘It is certain’;
break;
case 1:
eightBall = ‘Yes they are’;
break;
case 2:
eightBall = ‘Most of the time’;
break;
case 3:
eightBall = ‘Sometimes not’;
break;
case 4:
eightBall = ‘Yes, especially the big puppies’;
break;
case 5:
eightBall = ‘Not when the poop on the floor’;
break;
case 6:
eightBall = ‘They are adorable’;
break;
case 7:
eightBall = ‘Most definately’;
break;
}

console.log(The Magic 8 Ball says, ${eightBall}.)

1 Like