Fix spacing issue
This commit is contained in:
parent
a7fd6ca4e5
commit
322a14b9f8
1 changed files with 5 additions and 8 deletions
13
script.js
13
script.js
|
|
@ -12,28 +12,25 @@ function displayToScreen() {
|
|||
if (this.className == "equal") {
|
||||
let calc = new Calculator;
|
||||
|
||||
console.log(screen.textContent)
|
||||
screen.textContent = calc.calculate(screen.textContent);
|
||||
} else if (this.className == "clear") {
|
||||
screen.textContent = "0";
|
||||
} else {
|
||||
let screenContent = screen.textContent;
|
||||
|
||||
if (this.className == "operator") {
|
||||
screen.textContent += " ";
|
||||
let screenContent = screen.textContent;
|
||||
|
||||
for (let i = 0; i < screenContent.length; i++ ) {
|
||||
if (operators.includes(screenContent[i])) {
|
||||
let calc = new Calculator;
|
||||
|
||||
console.log(screen.textContent);
|
||||
result = calc.calculate(screen.textContent);
|
||||
screen.textContent += result;
|
||||
screen.textContent = result;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
screen.textContent += " " + this.textContent + " ";
|
||||
|
||||
screen.textContent += this.textContent + " ";
|
||||
} else if (screen.textContent === "0" && this.className == "num") {
|
||||
screen.textContent = this.textContent;
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in a new issue