-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
26 lines (25 loc) · 979 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
let string = " ";
let buttons = document.querySelectorAll('.button');
Array.from(buttons).forEach((button) => {
button.addEventListener('click', (e) => {
try {
if (e.target.innerHTML == '=') {
string = eval(string);
document.getElementById("Inp").value = string
} else if (e.target.innerHTML == 'C') {
string = "";
document.getElementById("Inp").value = string
} else if (e.target.innerHTML == 'X') {
string = string + '*';
document.getElementById("Inp").value = string
} else {
string = string + e.target.innerHTML;
document.getElementById("Inp").value = string
}
} catch (error) {
alert("Error! Please Enter Correct Value!!!");
string = "";
document.getElementById("Inp").value = string;
}
})
})