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