Code Your Own Adventure 2: Logical operators, "SyntaxError: Invalid or unexpected token"


#1

https://www.codecademy.com/courses/javascript-beginner-en-ZA2rb/0/5?curriculum_id=506324b3a7dffd00020bf661

This is my error message: "SyntaxError: Invalid or unexpected token"

This my code:

var user = prompt("You're cycling through the city on your way to Boxcar Social to do work, and you ride past Cannonball! Do you CONTINUE to Boxcar Social, STOP at Cannonball, or BLOW-OFF doing work entirely and go get drunk with your friends in the park?").toUpperCase();

switch(user) {
    case ‘CONTINUE’:
    var predicable = prompt("How predicable! Are you free-spirited (YES or NO)?”).toUpperCase();
    var bold = prompt("Are you bold?”).toUpperCase();
    if(predicable === 'YES' || bold === 'YES') {
      console.log("You only need one of the two! You’ll get your work done either way");
    } else {
      console.log("You might be bolder than you think! An unforgettable summer’s day could be in the cards for you after all”);
    }
    break;
    case ‘STOP’:
    var curious = prompt("How curious of you! You seem quite free-spirited, are you (YES or NO)?”).toUpperCase();
    var nervous = prompt("Are you nervous?”).toUpperCase();
    if(curious === 'YES' && nervous === 'YES') {
      console.log("You only need one of the two! You’ll get your work done and feel adventurous either way.");
    } else {
      console.log("You might be bolder than you think! An unforgettable summer’s day could be in the cards for you after all”);
    }
    break;
  case 'BLOW-OFF':
var courageous = prompt("How courageous of you! You seem quite brazen, are you (YES or NO)?”).toUpperCase();
    var fearless = prompt("Are you fearless?”).toUpperCase();
    if(courageous === 'YES' && fearless === 'YES') {
      console.log("You only need one of the two! You’ll get no work done and feel adventurous either way.");
    } else {
    console.log("Atta-boy! Summer-time day-drunk in the park with your homies is always the right choice!");
    break;
  default:
    console.log("Huh? Whatever that is is a much lesser option. Maybe you should just stay home instead.");
}

I've compared it to the example code that passes and still can't find my issue(s). Any advice would be greatly appreciated. Thank you.


#2

The colored syntax highlighting indicates a few issues. The non-standard right double quote seems to be the culprit. Replace all with ".


#3

Much appreciated! Sadly though, I've replaced them all and I'm still getting the same syntax error message. Can you see any other issues?


#4

Please repost your code in a new reply.


#5

var user = prompt("You're cycling through the city on your way to Boxcar Social to do work, and you ride past Cannonball! Do you CONTINUE to Boxcar Social, STOP at Cannonball, or BLOW-OFF doing work entirely and go get drunk with your friends in the park?").toUpperCase();

switch(user) {
    case 'CONTINUE':
    var predicable = prompt("How predicable! Are you free-spirited (YES or NO)?").toUpperCase();
    var bold = prompt("Are you bold?").toUpperCase();
    if(predicable === 'YES' || bold === 'YES') {
      console.log("You only need one of the two! You’ll get your work done either way");
    } else {
      console.log("You might be bolder than you think! An unforgettable summer’s day could be in the cards for you after all");
    }
    break;
    case 'STOP':
    var curious = prompt("How curious of you! You seem quite free-spirited, are you (YES or NO)?").toUpperCase();
    var nervous = prompt("Are you nervous?").toUpperCase();
    if(curious === 'YES' && nervous === 'YES') {
      console.log("You only need one of the two! You’ll get your work done and feel adventurous either way.");
    } else {
      console.log("You might be bolder than you think! An unforgettable summer’s day could be in the cards for you after all");
    }
    break;
    case 'BLOW-OFF':
var courageous = prompt("How courageous of you! You seem quite brazen, are you (YES or NO)?").toUpperCase();
    var fearless = prompt("Are you fearless?").toUpperCase();
    if(courageous === 'YES' && fearless === 'YES') {
      console.log("You only need one of the two! You’ll get no work done and feel adventurous either way.");
    } else {
    console.log("Atta-boy! Summer-time day-drunk in the park with your homies is always the right choice!");
    break;
  default:
    console.log("Huh? Whatever that is is a much lesser option. Maybe you should just stay home instead.");
}

#6

Found the culprit! I was missing a "}" on my last else statement.

Many thanks for your time!


#7

Unclosed else block.

    }
    break;
default:

#8

Connection problems meant my reply didn't appear when I posted it. Glad you discovered the error.