-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
43 lines (40 loc) · 1.25 KB
/
app.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
function getpin() {
const pin = Math.round(Math.random() * 10000);
const pinString = pin + "";
if (pinString.length == 4) {
return pin;
} else {
// console.log("got 3 digit and calling age",pin);
return getpin();
}
}
function generatePin() {
const pin = getpin();
document.getElementById("display-pin").value = pin;
}
document.getElementById("key-pad").addEventListener("click", function (event) {
const numbers = event.target.innerText;
const calcuInput = document.getElementById("type-numbers");
if (isNaN(numbers)) {
if (numbers == "C") {
calcuInput.value = "";
}
} else {
const previousCalu = calcuInput.value;
const newCalu = previousCalu + numbers;
calcuInput.value = newCalu;
}
});
function verifyPin() {
const pin = document.getElementById("display-pin").value;
const typeNumbers = document.getElementById("type-numbers").value;
const sucessNotification = document.getElementById("notify-success");
const failNotification = document.getElementById("notify-fail");
if (pin == typeNumbers) {
failNotification.style.display = "none";
sucessNotification.style.display = "block";
} else {
failNotification.style.display = "block";
sucessNotification.style.display = "none";
}
}