-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
54 lines (54 loc) · 1.9 KB
/
Copy pathscript.js
File metadata and controls
54 lines (54 loc) · 1.9 KB
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
44
45
46
47
48
49
50
51
52
53
54
let string = '';
let buttons = document.querySelectorAll(".keys");
Array.from(buttons).forEach((keys) => {
keys.addEventListener("click", (e) => {
let val= e.target.innerText;
if(val == '=')
{
string= eval(string);
document.querySelector(".count").value= string;
}
else
{
switch(val)
{
case 'AC':
string = "";
document.querySelector(".count").value = string;
break;
case 'DEL':
string = string.substring(0, string.length - 1);
document.querySelector(".count").value = string;
break;
case '.':
string = string + '.';
document.querySelector(".count").value = string;
break;
case '%':
string = string + '/100';
document.querySelector(".count").value = string;
break;
case '*':
string = string + '*';
document.querySelector(".count").value = string;
break;
case '/':
string = string + '/';
document.querySelector(".count").value = string;
break;
case '+':
string = string + '+';
document.querySelector(".count").value = string;
break;
case '-':
string = string + '-';
document.querySelector(".count").value = string;
break;
default:
string = string + val;
document.querySelector(".count").value = string;
console.log(val);
}
}
});
});