프로그래밍

조건문1

wonjae 2022. 1. 8. 12:38

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        var msg = "";
        var time = new Date().getHours();
        if (time < 12) {
            msg = "Good morning";
        }
        else if (time < 18) {
            msg = "good afternoon";
        }
        else if (time < 21) {
            msg = "good evening";
        }
        else {
            msg = "good nignt";
        }
        alert(msg);
    </script>
</head>
<body>
   
</body>
</html>