9.8 All on your own


#1

Hi, I cannot figure out what is wrong with my code. It says "Something is wrong with your syntax."

// Write your code below!
switch("Who is your vote going to?") {
    case 'trump':
        console.log("Trumpty dumpty!")
        break;
    case 'hillary':
        console.log("Why?");
        break;
    case 'markiplier':
        console.log("Good idea!");
        break;
    default:
        console.log ("Anything's better than Hillary!")
        break;


#2

I don't think you have to end your switch in a break if I am not mistaken and you might be missing a } at the end


#3

This is not the right syntax for a switch statement. If I remember the instructions correctly, you should declare a variable equal to a prompt. The user answers the prompt question and that is the input for the switch statement. @calvin.g.shaw, please share a link to the exercise so we're all on the same page.

You may find this useful:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/switch


#4

https://www.codecademy.com/courses/javascript-beginner-en-qDwp0/1/4?curriculum_id=506324b3a7dffd00020bf661

@biff75


#5

Thanks for the link. Did you make any changes to your code? @bibleman13's suggestion to add a closing curly brace was correct.


#6

Yes, I fixed it. Thank you guys for your help! :slight_smile:



#7

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