My Magic Eight ball project is not working. :(

Hi!
was solving magic-eight-ball exercise in Javascript. But the code doesn’t work even since I use all the hints and watch video. Could anyone see through my code and help to know what I messed up? :slight_smile: thank you very much.

----------------------------------code--------------------------------------
let userName = ‘isfp’;

userName ? console.log(Hello, ${userName}!) : console.log(‘Hello!’);

let userQuestion = ‘Will I become a werewolf tonight?’;

console.log(The user asked: ${userQuestion});

let 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 = ‘Reply 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;
}

console.log(eightBall);

----------------------------------error------------------------------------------

/home/ccuser/workspace/learn-javascript-U2P1/main.js:17
case 1;
^
SyntaxError: Unexpected token ;
at createScript (vm.js:53:10)
at Object.runInThisContext (vm.js:95:10)
at Module._compile (module.js:543:28)
at Object.Module._extensions…js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.runMain (module.js:605:10)
at run (bootstrap_node.js:427:7)
at startup (bootstrap_node.js:151:9)

:slight_smile: thank you

Looks like you put a semi-colon for case 1 instead of a colon like the other switch cases. It’s a pretty common error msg to get and gives a helpful pointing arrow to where the problem is. Just giving this info for next time you see a similar error msg. The error msg is saying the problem its on line 17 and next to case 1.

1 Like

Oh yes! thank you ! :cry:
If you are ok,… I got another question…

:cry:
I fixed 1; → 1: but still, there is a error in code… :cry:
If it is okay, let me know what is wrong in here… thank you very much!
Have a nice day :blush:

**/home/ccuser/workspace/learn-javascript-U2P1/main.js:27**
**    eightBall = 'Do not count on it;**. 
**                ^^^^^^^^^^^^^^^^^^^^**
**SyntaxError: Invalid or unexpected token**
**    at createScript (vm.js:53:10)**
**    at Object.runInThisContext (vm.js:95:10)**
**    at Module._compile (module.js:543:28)**
**    at Object.Module._extensions..js (module.js:580:10)**
**    at Module.load (module.js:488:32)**
**    at tryModuleLoad (module.js:447:12)**
**    at Function.Module._load (module.js:439:3)**
**    at Module.runMain (module.js:605:10)**
**    at run (bootstrap_node.js:427:7)**
**    at startup (bootstrap_node.js:151:9)**

No problem. Here you have a string that is not terminated. At the end of the string there is no single quotation mark (’) to show that it’s the end of the string. If you look at the error msg it says the problem is on line 27:

**/home/ccuser/workspace/learn-javascript-U2P1/main.js:27**