Need help,thanks


#1

switch(movie) {
case "Toy Story 2":
return "Great story. Mean prospector."
break
case "Finding Nemo":
return "Cool animation, and funny turtles."// return review here
break
default:
return "I don't know!"
}

The codes return with" There was a problem with your syntax."


#2

Hi @yuin_hsin,

Please see the code example below. I am not sure if you have omitted code or if this is the complete code you have written. In short there are a few minor syntax errors you would want to address EG: semi-colons etc. But your main problem I would guess is if this is all your code then you are attempting to return values out of a switch statement that is NOT part of a function. In short return is used in a function, is the lesson to take away here =)

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;
    }
};


getReview("Toy Story 2");