Magic eightball only prints default

[project](https://www.codecademy.com/paths/web-development/tracks/getting-started-with-javascript/modules/learn-javascript-control-flow/projects/magic-eight-ball-1
Here is my code. Im not sure what could be wrong at this point because i’ve been stuck for over an hour and a half now.
let userName = (‘levi’);
if (userName === ‘levi’)
console.log(‘Hello Levi!’);
let userQuestion = (‘Am I good at coding?’)
if (userQuestion === ‘Am I good at coding?’)
console.log(‘Am I good at coding?’)
const randomNumber = Math.floor(Math.random() * 8);
let eightBall = ‘’;
switch (randomNumber) {
case ‘0’ :
eightBall =(‘It is certain’)
break;
case ‘1’ :
eightBall =(‘it is decidedly so’)
break;
case ‘2’ :
eightBall =(‘really hazy try again’)
break;
case ‘3’ :
eightBall = (‘Cannot predict now’)
break;
case ‘4’ :
eightBall =(‘do not 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;
default:
console.log(‘no eigthBall found!’)
break;}
console.log(eightBall);
anybody know what’s wrong with this?

Your switch statement is checking randomNumber but your cases provide the strings of those numbers.

Do we really need all those brackets?

Isn’t, let userName = 'levi'; delimited enough?

1 Like

I’m sorry, I don’t understand what that means.

What @zeke0 is saying is that the data type of the value stored in randomNumber is ‘number’. Your cases are looking for a value of the data type ‘string’ (case ‘1’):

console.log(typeof 1 === 'number') // true 
console.log(typeof '1' === 'number') // false 
console.log(typeof '1' === 'string') // true 

I’m sorry I still don’t understand. What is wrong with my code or what is missing from it?

Why did you put the numbers in your cases in quote marks?

1 Like