I have to celebrate you, baby - code works, can't pass


#1


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


My code is behaving perfectly fine according to the instructions, but I receive the following error message:
"Are you sure you're returning the right thing?"

Any help would be greatly appreciated!


var getReview = function (movie) {

var movie;

    switch(movie==prompt("Which movie do you want read a review about?")){
    case "Toy Story 2":
        return console.log("Great Story. Mean prospector.");
        break;
    case "Finding Nemo":
         return console.log("Cool animation, and funny turtles.");
         break;
    case "The Lion King":
         return console.log("Great Songs.");
         break;
    default:
         return console.log("I don't know!");
    };

};


#2

The
var movie; line and prompt are not necessary. Simply remove the additional var and the prompt, and the code should work.


#3

That unfortunately doesn't work. It now simply prints "Great Story. Mean Prospector."


#4

Isn't that what it's supposed to do, assuming you're searching for the Toy Story 2 review?


#5

There's no input now. And it runs the code, defaulting to the Toy Story Review. Won't let me pass the exercise either. :confused:


#6

That's odd... what does your code look like now?


#7

var getReview = function (movie) {

    switch(movie){
    case "Toy Story 2":
        return console.log("Great Story. Mean prospector.");
        break;
    case "Finding Nemo":
         return console.log("Cool animation, and funny turtles.");
         break;
    case "The Lion King":
         return console.log("Great songs.");
         break;
    default:
         return console.log("I don't know!");
         break;
    };

};

#8

The only difference between yours and mine is the console.logs, but I don't see why that would make a difference.


#9

dude....i removed the console.log and it works........

thank you! but even worse is not knowing why it works.

I really want to know why the console.log trips it up. and why does a return statement print to the console without the console.log function.

Fatboy Slim wouldn't be pleased.


#10

I don't understand either. If java script were anything like java, the reason would be simply due to the nature of switches. But here, I don't know if that's the case.


#11

There's an exercise featuring the return function here from an earlier lesson:

https://www.codecademy.com/en/courses/javascript-beginner-en-6LzGd/1/3?curriculum_id=506324b3a7dffd00020bf661


#12

thanks biff, i'll revisit.


#13

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("Finding Nemo");

this is the right code


#14

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