4. I have to celebrate you baby


#1


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


it is printing out every thing in the code but it says i have to use the switch statment. please help.


var getReview = function (movie) {

};

var movie = prompt("Which movie do you want read a review about?");

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 think I have heard about your request?!");
}


#2

Try changing your case & default: to align with the instructions..

that takes in a movie name and returns its review based on the information above.
If given a movie name not found just return "I don't know!"

If you get stuck let me know and I'll further prompt :smiley:


#3

im confused can you say it to me in a different way


#4

You're console.log[ging] when you need to be using something else.. :wink:


#5

give me an example on what i have to do


#6

hello is anyone there


#7

lol..

I'm at work slash this is a forum so I wouldn't expect immediate responses :sweat_smile:

Within your case "Toy Story 2": you're console.log[ging[ ("Great Story. Mean prospector.");

Instead of console.log you need to use something else that is used within Javascript to return a value.. You're goal here is to not print the output the console but rather return it within the function..


#8

See w3schools information on Javascript's Return function for more information


#9

In the Functions lessons you would have learned about using return to send values back from a function. Since return is only valid inside a function, you are going to have a problem with your code because you have placed your switch statement outside of your getReview function.


#11

ok i put the code inside the function and changed all my "console.log" to "return".

heres the code.

var getReview = function (movie) {
var movie = prompt("Which movie do you want read a review about?");

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!");
}
};

#12

The code checker is calling your function to test that it works as expected. It is calling the function with various movie titles, like this:

getReview("Toy Story 2");
getReview("Finding Nemo");

Then it checks to see if it gets the expected result for that movie.

In your code you have prompted the user for the movie title. That is a nice touch, but can you see how that is causing a problem for the code checker?


#13

2 posts were split to a new topic: 4. Please tell me what I'm doing wrong, as the error says "Oops, try again. There was a problem with your syntax."


#15

Thak you! My code finaly work! Was not enough to call function onece.

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("Toy Story 2");
getReview("Finding Nemo");
getReview("The Lion King");
getReview("Cinderela");


#16