forked from 0xvashishth/CalcHub
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Log.js
75 lines (60 loc) · 1.77 KB
/
Log.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
let a = document.getElementById("base");
let base = 0;
a.addEventListener('input',function(){
base = a.value;
});
let argument = 0;
let b = document.getElementById("Argument");
b.addEventListener('input',function(){
argument = b.value;
});
let submit = document.getElementById("submit");
submit.addEventListener('click',function(){
let answer = 0;
if(base==='')
{
answer = Math.log(argument);
}
else
{
answer = Math.log(argument)/Math.log(base);
}
let ans = document.getElementById("ans");
ans.innerText = answer;
});
let reset = document.getElementById("Reset");
reset.addEventListener('click',function(){
document.getElementById("base").value='';
document.getElementById("Argument").value='';
document.getElementById("ans").innerText ="";
})
let antiBase = document.getElementById("Antibase");
let antiArgument = document.getElementById("AntiArgument");
let baseanti = 0;
let argumentanti = 0;
antiBase.addEventListener('input',function(){
baseanti = antiBase.value;
});
antiArgument.addEventListener('input',function(){
argumentanti = antiArgument.value;
});
let antiSubmit = document.getElementById("Antisubmit");
antiSubmit.addEventListener('click',function(){
let antiAnswer = 0;
if(baseanti==='')
{
antiAnswer = Math.exp(argumentanti);
}
else
{
antiAnswer = Math.pow(baseanti,argumentanti);
}
let ansAnti = document.getElementById("Antians");
ansAnti.innerText = antiAnswer;
});
let antiReset = document.getElementById("AntiReset");
antiReset.addEventListener('click',function(){
document.getElementById("Antibase").value='';
document.getElementById("AntiArgument").value='';
document.getElementById("Antians").innerText ="";
})