#4 I Have to Celebrate you Baby Syntax


#1

I used the following code and I keep getting "syntax error: unexpected token return":

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

console.log(getReview(ask));

However when I use the following code, I get no error.

var name = prompt("Which movie would you like to review");
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";
}
};
console.log(getReview(name));

var ask = prompt("What movie do you want to review?");

Can someone please explain what I'm missing in the first code-set that is in the second code set that causes it to not work.


#2

Here,

default
return "I don't know!";

You forgot the colon (:) after default