Looking for the Bug,movie review


#1

Why is this code not passing, it is telling that check your Toy Story 2. please help me out.

var getReview = function (movie) {

switch(movie){

case "Toy Story 2":
    return "Great story, Mean prospector.";

 case "Finding Nemo":
     return "Cool animation, and funny turtles.";

case "The Lion King":
    return "Great songs.";


    default:
    return "I don't know!";
  }

}


#2

While checking Toy Story 2, check that string youre returning is same as mentioned in instruction. It should be exact match.


#3

have seen the error, the first comma after the great story in the Toy Story 2 is suppose to be a full-stop. thank you .


#4

No need to be ';' semi colon at the end of the returns and need to place break statements after each return.
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;
}
}


#5

Semicolons aren't important?

they are.
Thus the break is not necessary here as return would be suffice


#6

Interestingly as you said it works without the "break" even with the ';' semi colon at the end of returns. I guess JS is kind a loose lang. :slight_smile: Thank you


#7

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