Help with Magic Eight Ball project


#1

Hello, it seems I am having a problem with this project. The console won't display the ball's answer.

var userQuestion = 'Will I ever become a programmer?';
var randomNumber = Math.floor(Math.random() * 7);
var eightBall = '';
switch(randomNumber) {
  case '0':
    eightball = 'It is certain';
    break;
  case '1':
    eightball = 'It is decidedly so';
    break;
  case '2':
    eightball = 'Reply hazy try again';
    break;
  case '3':
    eightball= 'Cannot predict now';
    break;
  case '4':
    eightball = 'Don\'t count on it';
    break;
  case '5':
    eightball = 'My sources say no';
    break;
  case '6':
    eightball = 'Outlook not so good';
    break;
  case '7':
    eightball = 'Signs point to yes';
    break;
                   }
console.log('The user asked: ' + userQuestion);
console.log('The eight ball answered: ' + eightBall);

The console only prints this out:

The user asked: Will I ever become a programmer?
The eight ball answered:

Is there a mistake in the code? Would greatly appreciate any advice.


#2

javascript is case sensitive.so eightBall and eightball is not same.

and here

case '0':

'0' and 0 is not same.

'0' is string and 0 is number.Anything in quotation marks is string.

you need number not string


#3

Thank you so much! Now it works just fine.