-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
75 lines (74 loc) · 2.43 KB
/
index.js
File metadata and controls
75 lines (74 loc) · 2.43 KB
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
A = ""
B = 0
output = 0
function calculate(N) {
if (N == "=") {
document.getElementById("operation").textContent = "="
if (operation == 1) {
output = Number(B) + Number(A);
console.log(output);
document.getElementById("firstvalue").textContent = ""
document.getElementById("secondvalue").textContent = output
}
else if (operation == 2) {
output = Number(B) - Number(A);
console.log(output);
document.getElementById("firstvalue").textContent = ""
document.getElementById("secondvalue").textContent = output
}
else if (operation == 3) {
output = Number(B) * Number(A);
console.log(output);
document.getElementById("firstvalue").textContent = ""
document.getElementById("secondvalue").textContent = output
}
else if (operation == 4) {
output = Number(B) / Number(A);
console.log(output);
document.getElementById("firstvalue").textContent = ""
document.getElementById("secondvalue").textContent = output
}
operation = 0
A = ""
B = 0
}
else if (N == "+") {
document.getElementById("operation").textContent = "+"
operation = 1
B = A
document.getElementById("firstvalue").textContent = B
document.getElementById("secondvalue").textContent = ""
console.log(B);
A = ""
}
else if (N == "-") {
document.getElementById("operation").textContent = "-"
operation = 2
B = A
document.getElementById("firstvalue").textContent = B
document.getElementById("secondvalue").textContent = ""
A = ""
}
else if (N == "*") {
document.getElementById("operation").textContent = "*"
operation = 3
B = A
document.getElementById("firstvalue").textContent = B
document.getElementById("secondvalue").textContent = ""
A = ""
}
else if (N == "/") {
document.getElementById("operation").textContent = "/"
operation = 4
B = A
document.getElementById("firstvalue").textContent = B
document.getElementById("secondvalue").textContent = ""
A = ""
}
else {
A = A + String(N)
A = Number(A)
document.getElementById("secondvalue").textContent = A
console.log(A);
}
}