Problem with my syntax


#1


https://www.codecademy.com/courses/spencer-sandbox/0/4?curriculum_id=506324b3a7dffd00020bf661


It keeps on telling me that there was a problem with my syntax. Could anyone tell me what's wrong with it?


var getReview = function (movie);
switch(movie)
{
    case "Toy Story 2":
        return "Great Story. Mean prospector.";
        break;
    case "Finding Nemo":
        return "Cool animation, and funny turtles.";
        break;
    case "The Lion King":
        return "Great songs.";
        break;
    default:
        return "I don't know!";
        break;
};


#2

Hi comrade! :slight_smile:

Here is your corrected code (look at it and compare with your):

var getReview = function (movie) {
switch(movie) {
case "Toy Story 2":
return "Great Story. Mean prospector.";
break;
case "Finding Nemo":
return "Cool animation, and funny turtles.";
break;
case "The Lion King":
return "Great songs.";
break;
default:
return "I don't know!";
break;
}
};

First: remove ";" in your first line and add {} (this is body or code block of your function in which is placed the switch statement)
Second: As I mentioned earlier your switch statement must nested in {} of your function

Here you can learn about the function syntax in JavaScript: http://www.w3schools.com/js/js_functions.asp

Hopefully this will help you... :wink:


#3

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