读书人

一个switch循环 说是SyntaxError: Une

发布时间: 2013-05-02 09:39:29 作者: rapoo

一个switch循环 说是SyntaxError: Unexpected token {
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 {
不知道哪里错了,各位给看看吧 switch 函数 js
[解决办法]


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!";
}
};

读书人网 >JavaScript

热点推荐