-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
27 lines (26 loc) · 1.03 KB
/
Copy pathscript.js
File metadata and controls
27 lines (26 loc) · 1.03 KB
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
const display = document.querySelector('#display');
const buttons = document.querySelectorAll('#button');
buttons.forEach((items) => {
items.onclick = () => {
if(item.id == 'clear') {
display.innerText = '';
} else if (item.id == 'backspace') {
let string = display.innerText.toString();
display.innerText = string.substr(0, string.lenght - 1);
}else if (display.innerText != '' && item.id == 'equal'){
display.innerText = eval(display.innerText);
}else if (display.innerText == '' && item.id == 'equal'){
display.innerText = 'Empty!';
setTimeout(() => (display.innerText = ''), 2000);
}
else {
display.innerText += item.id; } } })
const themeToggleBtn = document.querySelector('.theme-toggler');
const calculator = document.querySelector('.dark');
const togglerIcon = document.querySelector('.toggler-icon');
let isDark = true;
themeToggleBtn.onClick = () => {
calculator.classList.toggle('dark');
themeToggleBtn.classList.toggle('active');
isDark = !isDark;
}