forked from haxer-max/javascript_calculator
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
Latest commit
32 lines (30 loc) · 568 Bytes
/
Copy pathscript.js
File metadata and controls
32 lines (30 loc) · 568 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
29
30
31
32
vara=document.getElementById("area");
functionpress(i)
{
console.log(i)
a.value+=i;
}
functionClear()
{
a.value="";
}
//THIS FUNCTION WILL HELP IN REMOVING THE ISSUE WITH FLOATING POINT NUMBERS
functionstrip(number){
varno=parseFloat(number).toPrecision(12)
return(no*1).toString();
}
functionEval()
{
letp=a.value;
while(p.includes("^"))
{
p=p.replace('^',"**");
}
console.log(p);
lettemp=eval(p);
a.value=strip(temp);
}
functionback()
{
a.value=a.value.substring(0,a.value.length-1);
}