日期:2014-05-16  浏览次数:20677 次

一个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";
       &n