Magic Ball help - Code not working

My code isn’t running. It’s the first time is use the community so I don’t know how to properly ask something on code. I’ll paste the code, and then the error log I’m getting:

The code:

let userName = ‘Miguel’;
userName ? console.log(Hello, ${userName}) : console.log(‘Hello’);
let userQuestion = ‘Can you answer my question?’;
console.log(${userName} asked: ${userQuestion});
let randomNumber = Math.floor(Math.random() * 8);
let eightBall = ‘’;
if randomNumber === 0
eightBall = ‘It is certain’;
} else if randomNumber === 1 {
eightBall = ‘It is decidedly so’;
} else if randomNumber === 2 {
eightBall = ‘Reaply hazy try again’;
} else if randomNumber === 3 {
eightBall = ‘Cannot predict now’;
} else if randomNumber === 4 {
eightBall = ‘Do not count on it’;
} else if randomNumber === 5 {
eightBall = ‘My sources say no’;
} else if randomNumber === 6 {
eightBall = ‘Outlook not so good’
} else if randomNumber === 7 {
eightBall = ‘Signs point to yes’;
} else if randomNumer === 8 {
eightBall = ‘Not very probable’;
}

console.log(eightBall);


The error logs:

/home/ccuser/workspace/learn-javascript-U2P1/main.js:7
if randomNumber == 0
^^^^^^^^^^^^
SyntaxError: Unexpected identifier
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)

Thanks :slight_smile:

Hello, @migueltomarnogueira.

Welcome to the forums.

A quick review of the lesson on conditionals would probably help you out here.
https://www.codecademy.com/paths/web-development/tracks/getting-started-with-javascript/modules/learn-javascript-control-flow/lessons/control-flow

Also, please review this topic for future posts: How do I format code in my posts?

Your syntax for if statements is incorrect. A quick glance at the lesson should help. :wink:

1 Like

if (randomNumber === 0){
eightBall = ‘It is certain’;
}

!!! Thank you!!! :smiley:

1 Like

This topic was automatically closed 18 hours after the last reply. New replies are no longer allowed.