-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscriptfile.js
More file actions
54 lines (41 loc) · 1014 Bytes
/
scriptfile.js
File metadata and controls
54 lines (41 loc) · 1014 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
var a='';
var b='';
var ans='';
var num = [];
function callNum(digit)
{
num.push(digit);
if(num.length != 1)
{
a='';
document.getElementById('dis').innerHTML = a; // clearing the screen.
}
for(i=0; i<num.length; i++)
{
a=a+num[i]; // concatenate the elements of the array "num" into a single string, which will be displayed on the screen
}
document.getElementById('dis').innerHTML = a;
}
function calculate()
{
document.getElementById('dis').innerHTML = '';
// for(i=0; i<num.length ; i++)
// {
// b += num[i]; // concatenating the array "num" into a single string
// }
ans = eval(a);
document.getElementById('dis').innerHTML = ans; // result display
while(num.length > 0)
{
num.pop(); // emptying the array "num"
}
num.push(ans.toString());
}
function clrscr(){
document.getElementById('dis').innerHTML = '';
while(num.length > 0){
num.pop(); // emptying the array "num"
}
a ='';
b ='';
}