Advertisement
Guest User

Untitled

a guest
Oct 25th, 2021
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.71 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en-US">
  3. <head>
  4.      <meta charset="UTF-8">
  5.      <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6.      <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7.      <title>Should I Wake Up Today?</title>
  8.      <script>
  9.           "use strict";
  10.           /* Defining Table
  11.            * Input: Computer's clock
  12.            * Processing: Determine if the day of the week, month, and year is a day on which the user should wake up
  13.            * Output: Get up or sleep in
  14.            */
  15.           let date = new Date();
  16.           //console.log("Date obj: " + date);
  17.           date = date.toString();
  18.           //console.log("Date str: " + date);
  19.           let dateTrunc;
  20.           dateTrunc = date.substring(0, date.indexOf(":") - 8) + ".";
  21.           console.log(dateTrunc);
  22.           let message;
  23.           let isNYD = dateTrunc.includes("Jan") && dateTrunc.includes("01");
  24.           console.log(isNYD);
  25.           let isFOJ = dateTrunc.includes("Jul") && dateTrunc.includes("04");
  26.           console.log(isFOJ);
  27.           let isChr = dateTrunc.includes("Dec") && dateTrunc.includes("25");
  28.           console.log(isChr);
  29.           let isHoliday = isNYD || isFOJ || isChr;
  30.           console.log(isHoliday);
  31.           if (!(date.includes("Sat") || date.includes("Sun")) && isHoliday == false) {
  32.               message = "Get up!";
  33.           } else {
  34.                message = "Sleep in.";
  35.           }
  36.           function tell() {
  37.                document.getElementById("outputDiv").innerHTML = message;
  38.           }
  39.          
  40.       </script>
  41. </head>
  42. <body>
  43.      <button type=button onclick=tell()>Should I wake up today?</button>
  44.      <div id=outputDiv></div>
  45. </body>
  46. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement