-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
25 lines (25 loc) · 844 Bytes
/
script.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
let string = "";
let buttons = document.querySelectorAll('.button');
Array.from(buttons).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{
console.log(e.target);
if(e.target.innerHTML == 'X'){
string = string + '*';
document.querySelector('input').value = string;
}else if(e.target.innerHTML == '%'){
string = string + '/100';
document.querySelector('input').value = string;
}else{
string = string + e.target.innerHTML;
document.querySelector('input').value = string;
}
}
})
})