js判断星期几

<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- 判断星期几 0~6 -->
    <script>
        var s=prompt('请输入0~6的数字');
        var week=s-0;
        switch (week) {
            case 0:
            console.log("星期天");
            break;
            case 1:
            console.log("星期一");
            break;
            case 2:
            console.log("星期二");
            break;
            case 3:
            console.log("星期3");
            break;
            case 4:
            console.log("星期四");
            break;
            case 5:
            console.log("星期五");
            break;
            case 6:
            console.log("星期六");
            break;
            default:
            alert('请输入0~6的数字');
            break;
        }
    </script>
</body>
</html>
posted @ 2020-10-26 13:07  无敌臭弟弟  阅读(272)  评论(0编辑  收藏  举报