Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en-US">
- <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>Should I Wake Up Today?</title>
- <script>
- "use strict";
- /* Defining Table
- * Input: Computer's clock
- * Processing: Determine if the day of the week, month, and year is a day on which the user should wake up
- * Output: Get up or sleep in
- */
- let date = new Date();
- //console.log("Date obj: " + date);
- date = date.toString();
- //console.log("Date str: " + date);
- let dateTrunc;
- dateTrunc = date.substring(0, date.indexOf(":") - 8) + ".";
- console.log(dateTrunc);
- let message;
- let isNYD = dateTrunc.includes("Jan") && dateTrunc.includes("01");
- console.log(isNYD);
- let isFOJ = dateTrunc.includes("Jul") && dateTrunc.includes("04");
- console.log(isFOJ);
- let isChr = dateTrunc.includes("Dec") && dateTrunc.includes("25");
- console.log(isChr);
- let isHoliday = isNYD || isFOJ || isChr;
- console.log(isHoliday);
- if (!(date.includes("Sat") || date.includes("Sun")) && isHoliday == false) {
- message = "Get up!";
- } else {
- message = "Sleep in.";
- }
- function tell() {
- document.getElementById("outputDiv").innerHTML = message;
- }
- </script>
- </head>
- <body>
- <button type=button onclick=tell()>Should I wake up today?</button>
- <div id=outputDiv></div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement