forked from sat5297/hacktober-coding
-
Notifications
You must be signed in to change notification settings - Fork 0
/
calc.js
34 lines (24 loc) · 779 Bytes
/
calc.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
screen = document.getElementById('input').value;
let status=0;
function getinput(i){
if(i==='='){
document.getElementById('input').value=eval(document.getElementById('input').value)
}
else if(i=='+' || i=='-' || i=='*' || i=='/'){
if(status==0){
document.getElementById('input').value += i ;
status=1;
}
}
else if(i=='b'){
var value = document.getElementById("input").value;
document.getElementById("input").value = value.substr(0, value.length - 1);
}
else if(i=='c'){
document.getElementById('input').value='';
}
else{
document.getElementById('input').value += i ;
status=0;
}
}