Syntax error on if/else if/else - magic eigt ball

Hello my friends;

I’m doing the the Magic Eight Ball project. At the end of this project, I get an issue with “if” statements. I paste my entire code here plus a link to the project and a screenshot of the error:

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

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

console.log(${userName} asked ${userQuestion});

const 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 = ‘Reply 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 {
eightBall = ‘Signs point to yes’;


I must add that when I use control flow method (switch statements) no errors happen.

Hint: You’ve something on line 42 that’s the wrong colour.


syntax, syntax, and syntax. my friend.

never underestimate the power of reserved keywords or spelling of it.

1 Like

I’ve got it. The “if” keyword is capital. Thanks for the hint pal​:pray:t2::pray:t2:

1 Like

Thanks. I’ve found it out. I’ve written If instead of if.

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