Problem with conditionals working along random numbers

Hello everyone!

I am completing the project regarding conditionals in the JavaScript course (

I am having huge problems getting eightBall to display the messages I’d like it to.
I generate a randomNumber, and this works: I checked by logging randomNumber to the console.
However, eightBall does not display any messages whenever randomNumber = 0 || randonNumber > 2 is passed into it.

This is my code:

let userName = ‘Jane’;
userName ? console.log(Hello, ${userName}!) : console.log(‘Hello!’);
let userQuestion = ‘Will I fall in love?’;
console.log(The user asked: ${userQuestion});
let randomNumber = Math.floor(Math.random() * 8 );
let eightBall = ‘’;

switch(randomNumber) {
case 0:
eightball = ‘It is certain’;
case 1:
eightBall = ‘It is decidedly so’;
case 2:
eightBall = ‘Reply hazy try again’;
case 3:
eightball = ‘Cannot predict now’;
case 4:
eightball = ‘Do not count on it’;
case 5:
eightball = ‘My sources say no’;
case 6:
eightball = ‘Outlook not so good’;
case 7:
eightball = ‘Signs point to yes’;

Hey Gabriele, welcome to the forums!

You might want to double check for slight typos.

You currently have eightball and eightBall, and trying to log eightBall.

Well, that was an easy fix!
And also an embarrassing one. I manually typed the first two cases, then quickly realised that I could have made it quicker by copying-pasting it.
Little did I know I had copied one with the wrong format…

Thanks a lot! That small thing was driving me crazy.
I guess I learnt the lesson: always check spelling first!

1 Like