I have to celebrate you baby - extra printing?


#1


https://www.codecademy.com/courses/spencer-sandbox/0/4?curriculum_id=506324b3a7dffd00020bf661#


Oops, try again. Are you sure you're returning the right thing?

It's displaying the review for the title I search, but ALSO the review for the first "case." Not sure why!


var getReview = function (movies) {
    switch(movies) {
        case 'Toy Story 2':
            console.log("Great story. Mean prospectors.");
            break;
        case 'Finding Nemo':
            console.log("Cool animation, and funny turtles.");
            break;
        case "The Lion King":
            console.log("Great songs.");
            break;
        case "Avatar":
            console.log("The best!");
            break;
        default:
            console.log("I don't know!");
            break;
        };
};


getReview("Avatar")


#2

you need to return the review, so use the return keyword, not console.log()


#3

Ah, I see what's going wrong here. You're supposed to use

case "Title here":
return "review here";
break;

not console.log(), though you can use that at the end if you want. here's an example of my code to compare and contrast with, hope it helps. :slight_smile:

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

console.log(getReview("Toy Story 2"))

#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.