切换语句 - JavaScript

时间:2014-09-30 14:26:24

标签: javascript html

请参阅下面的JavaScript中的switch语句,同样不起作用。请告知错误。

function main(arg1){   
    switch(arg1) {
        case 'Jatin':
            alert('This is Jatin');
        break;
        case 'Vivek':
            alert('This is Vivek');
        break;
        case 'Vikas':
            alert('This is Vikas');
        break;
        default:
            alert('The name is not found');
    };
    main("Jatin");

1 个答案:

答案 0 :(得分:0)

function main(arg1){   
     switch(arg1) {
         case 'Jatin':
             alert('This is Jatin');
         break;
         case 'Vivek':
             alert('This is Vivek');
         break;
         case 'Vikas':
             alert('This is Vikas');
         break;
         default:
             alert('The name is not found');
     } // no semi colon
} // closing brace

main("Jatin");