1. 程式人生 > >用switch語句判斷月份,打印出當前月份所在的季節

用switch語句判斷月份,打印出當前月份所在的季節

class nth htm html ase date() div IT AS

 var today=new Date();
    var abc=today.getMonth();
    switch (abc) {
        case 0:
            document.write("現在是春季");
            break;
        case 1:
            document.write("現在是春季");
            break;
        case 2:
            document.write("現在是春季");
            break;
        case 3:
            document.write("現在是夏季");
            break;
        case 4:
            document.write("現在是夏季");
            break;
        case 5:
            document.write("現在是夏季");
            break;
        case 6:
            document.write("現在是秋季");
            break;
        case 7:
            document.write("現在是秋季");
            break;
        case 8:
            document.write("現在是秋季");
            break;
        case 9:
            document.write("現在是冬季");
            break;
        case 10:
            document.write("現在是冬季");
            break;
        case 11:
            document.write("現在是冬季");
            break;
    }

  

用switch語句判斷月份,打印出當前月份所在的季節