用switch语句判断月份,打印出当前月份所在的季节

Posted 麦克斯-侯的博客

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了用switch语句判断月份,打印出当前月份所在的季节相关的知识,希望对你有一定的参考价值。

 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语句判断月份,打印出当前月份所在的季节的主要内容,如果未能解决你的问题,请参考以下文章