7. I have to celebrate you baby. I don't know what's happening!


#1

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

Hi everyone, I'm a total newbie to coding and I don't understand what is happening here. When I run the getReview function, it always logs the review for "Toy Story 2" even if I don't ask for it. Any ideas?

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.");
            break;
        default:
            console.log("I don't know!");
            break;
    }
};
.


#2

Try refreshing the browser. I ran the code on https://repl.it and it seemed fine.


#3

Don't use console.log(); The instructions say that it wants you to return these strings, not log it. Use return(); .


#4

thank you all! I used return() and it works perfectly


#5

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

it works.


#6

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