var getReview = function (movie) {
switch(movie){
case(Matrix){
return"good trip out";
}
case(Princess Bride){
return"awesome date night movie";
}
case(Welcome to America){
return"Amjad's favorite";
}
case(Remember the Titans){
return"love the sports";
}
case(Why do I look like ) {
return"The Ryan and Zach story";
}
毕业论文
case(Fighting Kangaroos in the wild){
return "Token Australian movie for Leng";
}
fault{
return"I don't know!";
}
}
};
getReview(Princess Bride);
SyntaxError: Unexpected token {
不知道哪里错了,各位给看看吧
var getReview = function (movie) { switch(movie){ case "Matrix": //case语法错误 而且字符串要用引号括起来。 return"good trip out"; case "Princess Bride": return"awesome date night movie"; case "Welcome to America": return"Amjad's favorite"; case "Remember the Titans": return"love the sports"; case "Why do I look like": return"The Ryan and Zach story"; case "Fighting Kangaroos in the wild": return "Token Australian movie for Leng"; //fault //这里是不是拼写错误? default : return"I don't know!"; } };
双引号里面用单引号。。如果单引号里面用单引号需要转义
case'Why do I look like I\'m 12?': //注意要转义
1234567891011121314151617181920212223242526272829 var getReview = function (movie) { switch(movie){ case "Matrix": //case语法错误 而且字符串要用引号括起来。 return"good trip out"; case "Princess Bride": return"awesome date night movie"; case "Welcome to America": return"Amjad's favorite"; case "Remember the Titans": return"love the sports"; case "Why do I look like I'm 12?": return"The Ryan and Zach story"; case "Fighting Kangaroos in the wild": return "Token Australian movie for Leng"; //fault //这里是不是拼写错误? default : return"I don't know!"; } }; getReview("Matrix");