-
Notifications
You must be signed in to change notification settings - Fork 0
/
Index.js
39 lines (37 loc) · 1.04 KB
/
Index.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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
let AllBox=document.querySelectorAll('.B');
AllBox.forEach(element =>
{
element.addEventListener('click' , ()=>
{
if(element.innerHTML==='C')
{
document.querySelector('.Inp').value='';
}
else if(element.innerHTML==='=')
{
try
{
let Exp=document.querySelector('.Inp').value;
if(Exp.search('^')>=0)
{
Exp=Exp.replaceAll('^' , '**');
}
let Ans=eval(Exp);
document.querySelector('.Inp').value=Ans;
}
catch
{
document.querySelector('.Inp').value="Expression Wrong";
}
}
else
{
document.querySelector('.Inp').value+=element.innerHTML;
}
});
});
document.querySelector('.form-check-input').addEventListener('click' , ()=>
{
document.querySelector('.Main').classList.toggle('Dark');
document.querySelector('body').classList.toggle('Body-Dark');
});