-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
31 lines (27 loc) · 993 Bytes
/
Copy pathscript.js
File metadata and controls
31 lines (27 loc) · 993 Bytes
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
let string = "";
let button = document.querySelectorAll('.button');
Array.from(button).forEach((button)=> {
button.addEventListener('click', (e)=> {
if(e.target.innerHTML == '=') {
string = eval(string);
document.querySelector('input').value = string;
}
else if (e.target.innerHTML == 'C') {
string = '';
document.querySelector('input').value = string;
}
else if (e.target.innerHTML == 'backspace') {
string = string.substring(0, string.length - 1);
document.querySelector('input').value = string;
}
else if (e.target.innerHTML == 'e') {
string = string + Math.E;
document.querySelector('input').value = string;
}
else {
console.log(e.target);
string = string + e.target.innerHTML;
document.querySelector('input').value = string;
}
})
})