4/13 Whats wrong with this?


#1

var getReview = function (movie) {
var film = prompt("What film do you want reviewd?").toLowerCase()

switch(film) {
    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;
    };

};

getReview()


#2

This is the right code :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!";

}
};


#3

This works like a char:

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 'Great songs':
return "Great songs.";
break;
default:
return "I don't know!";
break;

}
};

console.log(getReview('The Lion King'));


#4

This is the correct code

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');


#5

I am getting "Oops, try again. Check the review of Toy Story 2" on executing below code:

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("The Lion King")

what is the error?


#6

you should check the review of Toy Story 2, not the Lion King.
getReview("Toy Story 2");


#7

i did still shows the same error...


#8

You've forgot the semicolon ";" after the return statement. Make sure to check your syntax before submitting code. Here's the right code.

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("The Lion King")

#9

//This seems to do the job too!

var question = prompt("What movie would you like me to review?");

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 dont know!");
    break;

}
};

getReview(question);