-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
29 lines (26 loc) · 919 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const input = document.querySelector("input");
const output = document.querySelector("#output");
const button = document.querySelector("button");
const form = document.querySelector("form");
let isLoggedin = false;
let password = "Pass";
let attempts = 0;
let attemptsLimit = 3;
form.addEventListener("submit", (e) => {
e.preventDefault();
});
const authenticateUser = () => {
if (input.value != password && !isLoggedin && attempts < attemptsLimit) {
attempts++;
console.log(attempts);
} else if (input.value === password) {
isLoggedIn = true;
form.style.display = "none";
output.style.display = "inherit";
output.innerHTML = `The <span class="underline"> answer</span> to the ultimate question of life, the universe and everything is <span class="underline">42</span>`;
} else {
message.innerHTML = "Too many entries";
form.style.display = "none";
}
input.value = "";
};