-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
77 lines (68 loc) · 1.28 KB
/
script.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
74
75
76
77
var num1=0;
var num2=0;
var total=0;
var i=0;
var j=0;
var sum=0;
var x="";
a = new Array(5);
function cal(n)
{
j=i;
i++;
x+=document.getElementById(n).value;
console.log(x);
document.getElementById("screen").value=x;
/* var y=document.getElementById("S").value;*/
}
/*
if(x=="+")
{
add(a);
}
else if(x=="-")
{
sub(a);
}
else if(x=="*")
{
mul(a);
}
else if(x=="/")
{
div(a);
}
a[i]=x;
}
*/
function add()
{
console.log("##### "+a[i]+" "+i+" "+j);
sum=+a[i] + +a[j];
console.log("sum is: "+sum);
eval();
}
function eval1()
{
var k;
for (k = 0; k < a.length; k++) {
console.log("your array: "+a[k]);
}
console.log("****************");
console.log(x);
for(k=0;k<x.length;k++)
{
console.log("^^ "+x.charAt(k));
num1=parseInt(x.charAt(k));
if(x.charAt(k)=='+')
{
console.log("$$$$$$ num" +num1);
num1=+num2 + +parseInt(x.charAt(++k));
}
else{
num2=num1;
}
}
console.log("total is "+num1);
document.getElementById("screen").value=num1;
}