I'm not celebrating you baby...I've got errors


#1

When I run my code, I get my prompt. I enter The Lion King,and it returns that review.However, it then returns the review for Toy Story 2 and then it returns the default review. I thought my code looked okay, but obviously not. Can somebody take a look at my code and point out what is wrong? Thank you.

Here is my code.

var name = prompt("Which movie would you like to review?")
var getReview = function (movie) {
switch(movie) {
case "Toy Story 2":
console.log("Great story. Mean prospector.");
break;
case "Finding Nemo":
console.log("Cool animation, and funny turtles.");
break;
case "The Lion King":
console.log("Great songs.");
default:
console.log("I don't know!");
}
};
getReview(name);


#2

You're missing a break from the second-last case ("The Lion King").

Also, you should avoid using name as a variable name in Javascript as it's one of the built-in properties and thus may throw errors at some point. There's a list of words you can't/shouldn't use here. :slightly_smiling:

P.S. Please don't forget to use markdown (use the 'preformatted text' button at the top of the editor) to format code you paste into the Q&A forums, as it makes things much easier to read :wink:


#3

@dubsnstuff

Also look here

You are missing a semicolon. Your switch statement doesn't seem right. Don't store it inside a variable and you don't need to call your switch statement. So remove this line too:


#4

/*Try it*/

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!";
}
};
getReview(name);