Hi all,
I want the function below to return the review for the movie when I input the movie title into my function. Right now it’s not working. Any suggestions?
var movLibrary = {
movie1: {
title: ["Toy Story 2"],
review: ["Great story. Mean prospector."]
},
movie2: {
title: ["Finding Nemo"],
review: ["Cool animation, and funny turtles."]
},
movie3: {
title: ["The Lion King"],
review: ["Great songs."]
}
};
var getReview = function(movie) {
for (var x in movLibrary) {
if (movLibrary[x]["title"] === movie) {
return movLibrary[x]["review"];
}
else {
return "Please try again";
}
}
};
getReview("Finding Nemo");