4/33 "no switch statement" error


#1

Screenshot: http://prntscr.com/8rgxez

It seems like I do have a switch statement. What am I doing wrong? ;p


#2

It is much easier for us to help if you just post your code, rather than a screenshot.


#3

Ah, that would be my bad. Here it is:

var getReview = function (movie) {
var name = prompt("What movie?");
switch(name) {
    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();

free format - please learn how to post code


#4
var getReview = function (movie) {
    // 
};

getReview();

Does this look strange? It should. Spot the difference? Hint... movie.

The place to get information from a user is not in the function, but before the call to it.

var name = prompt("What movie?");
getReview(name);

Then in the function,

var getReview = function (movie) {
    switch (movie) {
    case "...": return "...";
    case "...": return "...";
    case "...": return "...";
    default: return "I don't know.";
    }
};

Keep in mind that break is unreachable after return.


#5

Thanks a lot, that helped!