I have to celebrate you baby


#1

hi ,it doesnot work .
what is wrong with it ?

var name=prompt(“Toy Story 2,Finding Nemo ,or The Lion King”);

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(name);


#2

You have to use the EXACT texts…


#3

hi @leonhard.wettengmx.n
i copied them again .ok .it is ok
but i have a question ,why it did not use break ;?
because in switch , every case need a break to stop the statement .
why in the program, it does not need the break ?
thanks


#4

how you can find the difference .
i do not know the difference ,i did not find the difference ,only copied the words to pass the lesson
thanks


#5

You are using the return statement
and after the return statement has been =executed= it will EXIT the current-scope
in this case the switch() and therefor the =break= is not need for the specific CASE.

The same would happen if the return statement is used in a function()

google search
=the book=
javascript variable site:developer.mozilla.org
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/var
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Values,_variables,_and_literals
javascript return statement site:developer.mozilla.org
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/return
=discussions=
javascript return statement site:stackoverflow.com
http://stackoverflow.com/questions/3717420/is-there-a-benefit-to-using-a-return-statement-that-returns-nothing
http://stackoverflow.com/questions/22134753/return-statement-in-javascript


#6

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