Eight Ball


#1

https://www.codecademy.com/courses/learn-javascript/projects/magic-eight-ball

I am stuck on the project were i create an eight ball with code.

It doesn’t print out what the eightball says about my question.

```

var userQuestion = ‘Am I a potato?’;
var randomNumber = Math.floor(Math.random() * 7);
var eightBall = ‘’;
switch (eightBall) {
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 sorces say no’;
break;
case ‘6’:
eightBall = ‘Outlook not os good’;
break;
case ‘7’:
eightBall = ‘Signs point to yes’;
break;
};
console.log('The user asked: ’ + userQuestion);
console.log('The eight ball answered: ’ + eightBall);


#2

eightBall = 'Don't count on it';

Error comes from this line.If you need a ' in string then use "" for that string.for example:

"i'm user"

now look at here

switch (eightBall)

you used eightBall for switch case.but the value of eightBall is always an empty string. So you’ll not get any expected results. Do something so that the value of eightBall can be change randomly between 0 to 7.

now if you want to return a number between 0 (inclusive) to 7 (inclusive) then you need to use

Math.random() * 8

because Math.random() returns a number between 0 (inclusive) to 1 (exclusive).


#3

Your code is screening for strings but since you are looking for var randomNumber which is a number despite being random it should be case 0: instead of case ‘0’: .