-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
99 lines (84 loc) · 3.57 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
function myFunction(t) {
if (t==0) {
document.getElementById("demo").value += document.getElementById("button0").innerHTML;
}
if (t==1) {
document.getElementById("demo").value += document.getElementById("button1").innerHTML;
}
else if (t==2){
document.getElementById("demo").value += document.getElementById("button2").innerHTML;
}
else if (t==3){
document.getElementById("demo").value += document.getElementById("button3").innerHTML;
}
else if (t==4){
document.getElementById("demo").value += document.getElementById("button4").innerHTML;
}
else if (t==5){
document.getElementById("demo").value += document.getElementById("button5").innerHTML;
}
if (t==6) {
document.getElementById("demo").value += document.getElementById("button6").innerHTML;
}
if (t==7) {
document.getElementById("demo").value += document.getElementById("button7").innerHTML;
}
if (t==8) {
document.getElementById("demo").value += document.getElementById("button8").innerHTML;
}
if (t==9) {
document.getElementById("demo").value += document.getElementById("button9").innerHTML;
}
}
function myFunction2(y) {
if (y==1){
document.getElementById("demo").value += document.getElementById("button10").innerHTML;
}
else if (y==2){
document.getElementById("demo").value += document.getElementById("button11").innerHTML;
}
else if (y==3){
document.getElementById("demo").value += document.getElementById("button12").innerHTML;
}
else if (y==4){
document.getElementById("demo").value += document.getElementById("button13").innerHTML;
}
}
function cancel(){
document.getElementById('demo').value = "";
}
function equalTo(){
var result = document.getElementById("demo").value;
if(result.includes(" + +")){
document.getElementById("demo").value += "";
}
else if(result.includes("+")){
var value_1 = document.getElementById("demo").value.split("+")[0];
var value_2 = document.getElementById("demo").value.split("+")[1];
document.getElementById("demo").value += " "+ " "+"=" +" "+ " "+Number(Number(value_1) + Number(value_2));
}
else if(result.includes(" - -")){
document.getElementById("demo").value += "";
}
else if(result.includes("-")){
var value_1 = document.getElementById("demo").value.split("-")[0];
var value_2 = document.getElementById("demo").value.split("-")[1];
document.getElementById("demo").value += " "+ " "+"=" +" "+ " "+Number(Number(value_1) - Number(value_2));
}
else if(result.includes(" * *")){
document.getElementById("demo").value += "";
}
else if(result.includes("*")){
var value_1 = document.getElementById("demo").value.split("*")[0];
var value_2 = document.getElementById("demo").value.split("*")[1];
document.getElementById("demo").value += " "+ " "+"=" +" "+ " "+Number(Number(value_1) * Number(value_2));
}
else if(result.includes(" / /")){
document.getElementById("demo").value += "";
}
else if(result.includes("/")){
var value_1 = document.getElementById("demo").value.split("/")[0];
var value_2 = document.getElementById("demo").value.split("/")[1];
document.getElementById("demo").value += " "+ " "+"=" +" "+ " "+Number(Number(value_1) / Number(value_2));
}
}