Not sure what I'm missing :(


#1

I don't know where I'm going wrong here. When I run the code it just prints "What is your purpose?"

var userQuestion = 'What is your purpose?';
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(userQuestion);
console.log(eightBall);

#2

This should be * 8.

The cases should be integer, not string.


#3

Thank you. Something simple as I figured!

Could you explain why that would be *8 though?


#4

Math.random() will be less than 1, meaning when we multiply by 8 it will be number less than 8. When we floor it, we get a range of 0..7.


#5

Gotchya. Thanks a lot!