-
Notifications
You must be signed in to change notification settings - Fork 0
/
logic.js
42 lines (42 loc) · 1018 Bytes
/
logic.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
var one="";
var two="";
var operator="";
function Myclear(){
document.getElementById("answer").value="";
}
function Clear_last(){
let text = document.getElementById("answer").value;
let len = text.length;
let ans=text.slice(0,len-1);
document.getElementById("answer").value=ans;
}
function Mywrite(num){
var temp=document.getElementById("answer").value;
if(temp.length==1&&temp=="0")
temp="";
temp=temp+num;
document.getElementById("answer").value=temp;
}
function Myoperator(op){
one=document.getElementById("answer").value;
document.getElementById("answer").value="";
operator=op;
}
function Myoutput(){
two=document.getElementById("answer").value;
let x=parseInt(two);
let y=parseInt(one);
let ans="";
if(operator=="/")
ans=one/two;
else if(operator=="*")
ans=one*two;
else if(operator=="-")
ans=one-two;
else
ans=x+y;
one="";
two="";
operator="";
document.getElementById("answer").value=ans;
}