If today is neither Saturday nor Sunday, write a default message: - Javascript Statement

Javascript examples for Statement:switch

Description

If today is neither Saturday nor Sunday, write a default message:

Demo Code

ResultView the demo in separate window

<html>
<body>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {/* w ww. j a  v a  2 s.c o  m*/
    var text;
    switch (new Date().getDay()) {
        case 6:
            text = "Today is Saturday";
            break;
        case 0:
            text = "Today is Sunday";
            break;
        default:
            text = "Looking forward to the Weekend";
    }
    document.getElementById("demo").innerHTML = text;
}
</script>

</body>
</html>

Related Tutorials