Skip to content

Commit 9d4b61f

Browse files
Merge pull request #3 from gskls/master
Fixed CE button now it's working
2 parents e0ca991 + dc5eeb1 commit 9d4b61f

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

javaScriptCalculator/script.js

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class Calculator {
5454
this.state.monitor.push(id);
5555
this.state.output = this.state.monitor.join("");
5656
this.render();
57-
console.log(this.state.monitor);
57+
console.log(this.state)
5858
}
5959

6060
deleteAll() {
@@ -66,28 +66,36 @@ class Calculator {
6666
this.leaveZero();
6767
}
6868

69-
// not wroking
7069
backOne() {
71-
this.state.monitor.pop();
72-
this.state.output = this.state.monitor.join("");
73-
this.render();
74-
console.log(this.state.monitor)
75-
if (this.state.output === "") {
76-
this.state.output = "0";
70+
var monitor = [];
71+
var state = this.state;
72+
73+
for (var i = 0; i < state.monitor.length - 1; i++) {
74+
monitor[i] = state.monitor[i].toString().split("")
7775
}
76+
77+
this.state = {
78+
monitor: monitor,
79+
output: monitor.join("")
80+
}
81+
82+
if (state.output === "") {
83+
state.output = "0";
84+
}
85+
this.render();
7886
}
7987

8088
total() {
8189
// give something wrong and see how it works
82-
try{
90+
try {
8391
var total = eval(this.state.monitor.join(""));
84-
}catch(e){
92+
} catch (e) {
8593
total = e;
8694
}
8795

8896
this.state = {
8997
output: total,
90-
monitor: [].concat(total)
98+
monitor: total.toString().split("")
9199
};
92100
this.render();
93101
}

javaScriptCalculator/style.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
* {
22
padding: 0;
33
margin: 0;
4-
box-sizing: border-box;
54
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
65
border: 0;
76
}
@@ -57,6 +56,8 @@ body {
5756
}
5857
.calBody{
5958
background: rgb(145, 215, 255);
59+
border-bottom-left-radius: 5px;
60+
border-bottom-right-radius: 5px;
6061
}
6162

6263
#steps{

0 commit comments

Comments
 (0)