首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

一个switch循环 说是SyntaxError: Unexpected token {,该如何处理

2013-05-02 
一个switch循环 说是SyntaxError: Unexpected token {var getReview function (movie) {switch(movie){c

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

热点排行