4. I have to celebrate you baby


#1

Where am I going wrong here? Thanks

var getReview = function (movie) {
swtich(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!";
}
};


#2

check the spelling of switch :slight_smile:

also

return "Great Story. Mean prospector.";
break; //unreachable 'break' after return

The return statement stops the execution of a function and returns a value from that function.


#3

Sorry, are you saying that the 'break' is not needed because 'return' is used?


#5

yes,you can say that :slight_smile:


#6

I had that same problem. I made sure that my switch was spelled correctly and I tried it with the break; and without the break; and it still wouldn't work

here is my code :

var getReviews= 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!";
}
};
getReviews("Toy Story 2");


#7

what's the error massage ?



Don't post on other's topic.create a new one :slight_smile:


#8

you have to break;

case "The Lion King":
return "great songs";
break;


#9

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