Magic Eightball Project in JS "Unexpected identifier at wrapSafe"

Hello hello, I wrote out the code for this project but I keep getting weird errors and I’m not sure what’s going on:

let userName = 'Chris';

userName === 'Chris' ? console.log(`Hello ${userName}`) || console.log('Hello!')

const userQuestion = 'Is the sky blue?';
console.log(`Your question was: ${userQuestion}`);

let randomNumber = Math.floor(Math.random() * 8);

let eightBall = '';

switch (randomNumber) {
    case 1:
        eightBall = 'It is certain'

    case 2:
        eightBall = 'It is decidedly so'

    case 3:
        eightBall = 'Reply hazy try again'

    case 4:
        eightBall = 'Cannot predict now'

    case 5:
        eightBall = 'Do not count on it'

    case 6:
        eightBall = 'My sources say no'

    case 7:
        eightBall = 'Outlook not so good'

    case 8:
        eightBall = 'Signs point to yes'


console.log(`Your answer is: ${eightBall}`);

The problem seems to be this line: const userQuestion = ‘Is the sky blue?’;
This line seems to throw an error of “SyntaxError: Unexpected token ‘const’ at wrapSafe”
If I change it to “let” I get this error “SyntaxError: Unexpected identifier ‘let’ at wrapSafe”

Any advice for this one?

Hello @text9369870380, welcome to the forums!
Remember a ternary expression takes the form:

condition ? expression1 : expression2

You’ve used a || (or operator) instead of the colon (:).

1 Like

Hello @codeneutrino! I feel silly for missing that one! Works perfectly now! Thanks a ton for the help!!

1 Like

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