-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
23 lines (20 loc) · 664 Bytes
/
main.js
File metadata and controls
23 lines (20 loc) · 664 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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 == 'AC'){
string = "";
document.querySelector('.input').value = string;
}
else{
console.log(e.target);
string = string + e.target.innerHTML;
console.log(string);
document.querySelector('input').value = string;
}
});
});