-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
28 lines (24 loc) · 879 Bytes
/
Copy pathmain.js
File metadata and controls
28 lines (24 loc) · 879 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
console.log('javascript is linked!');
let calcButtons = document.querySelectorAll('.button');
console.log('Buttons added', calcButtons);
const display = document.getElementById('Display');
console.log('display updated');
//**all buttons have to have class button^^ */
for (let button of calcButtons) {
button.addEventListener('click', (Event) => {
if (Event.target.id !== 'eval') {
display.innerText += Event.target.id;
console.log(Event.target.id);
}
if (Event.target.id === 'clear') {
display.innerText = "";
console.log("That's how you clear it!");
}
if (Event.target.id === 'eval') {
let result = eval(display.innerHTML);
display.innerText = result;
console.log(result);
console.log('equals clicked');
}
});
}