4/33 "I have to celebrate you baby" - need help here plz


#1

var review = prompt("what movie have u watched").toUpperCase();
var getReview = function (movie) {
//this.movie = 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;

}
};
getReview(name);

no matter what i do, the output is always the default part. I don't understand why? someone plz help me solve this problem? Thanks a lot !!!!


#2

I think the problem is that you're return a variable called name, rather than the prompt output "review" - try: getReview(review) instead.

Also, if you use to Upper Case in the prompt, you'd have to match each of the cases with uppercase letters (e.g. THE LION KING). This was giving me a lot of trouble since for this exercise the interface expects the output to match exactly, i.e. The Lion King. Easiest thing is to take out the toUpperCase() altogether, and just type it the same way when it prompts you.

This code worked for me:

var review = prompt("what's your favorite movie")

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(review)


#3

oh i see. What a silly mistake i made :stuck_out_tongue_winking_eye: Thank u very much


#4

By the way, could u explain to me why the argument when calling the getReview function has to be "review", but not "getReview" or "movie"? What are its purposes & roles in executing this code block? Thanks in advance


#5

send string value to the function
for ex getReview("The Lion King")


#6

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;

}
};
getReview("The Lion King");

try this it works


#7

oh ok , thank u very much :smile: