Browse Source

redid hw with debugger and variables done

OleksiiL 1 year ago
parent
commit
86b76e03d4
2 changed files with 33 additions and 8 deletions
  1. 3 0
      Homework_12/index.html
  2. 30 8
      Homework_12/main.js

+ 3 - 0
Homework_12/index.html

@@ -9,6 +9,9 @@
 </head>
 
 <body>
+    <form id="box">
+        <input type="button" name="" value="Login" onclick="Input()">
+    </form>
     <script src="/main.js"></script>
 </body>
 

+ 30 - 8
Homework_12/main.js

@@ -1,10 +1,32 @@
-let calories =
-  +prompt("How many calories do you eat for breakfast?", 700) +
-  +prompt("How many calories do you eat for lunch?", 500) +
-  +prompt("How many calories do you eat for dinner?", 400);
-alert(`you eat ${calories} for breakfast`);
+// Simple calories calculator-------------------------------------------------------------------------
 
-let message = "you are eating enough calories";
-if (calories >= 1800) message = "you are eating too many calories";
+// let breakfastEats = +prompt("How many calories do you eat for breakfast?", []);
+// let lunchEats = +prompt("How many calories do you eat for lunch?", []);
+// let dinnerEats = +prompt("How many calories do you eat for dinner?", []);
 
-alert(message);
+// let caloriesOfTheDay = breakfastEats + lunchEats + dinnerEats;
+
+// if (caloriesOfTheDay > 1800) {
+//   alert("You are eating too many calories");
+// } else {
+//   alert(
+//     "Everything is fine, you did not exceed the number of calories for the day"
+//   );
+// }
+
+// Login form--------------------------------------------------------------------------------------------
+const box = document.body;
+
+function Input() {
+  user_name = "";
+  password = "";
+  user_name = prompt("Login", []);
+  user_name = user_name.toLowerCase();
+  password = prompt("Password", []);
+  password = password.toLowerCase();
+  if (user_name == "admin" && password == "qwerty") {
+    box.style.backgroundColor = "green";
+  } else {
+    box.style.backgroundColor = "red";
+  }
+}