Telling me to use a switch statement, but I have one. exercise 4


#1

Here's my code. It's telling me to use a switch statement, but I clearly have one. The function also returns the correct reviews. I have no idea what is wrong here.

I also built a useless switch statement outside of the function, to see if that would clear the message. It didn't.

Any help would be great!

*Line one was cut out of the screenshot, but it's
var movie1 = new Object();


#2

I think you need to create getReview as a variable.

var getReview = function() {
};

Right now, I think the Javascript is just ignoring it, and jumping to the prompt.

Also, you can simplify this a lot if you just add a parameter to your function:

var getReview = function (movie) {
    switch(movie) {
        case "Toy Story 2":
            return "Great story. Mean prospector.";
            break;

...and so on.


#3

I added "var" in front of getReview, and it didn't change anything.

I tried your simplification, and it still says "better use a switch statement"

Is there a reason it is still telling me to use a switch statement?


#4

this may help us:

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

};

you make it too long ..and that's useless.