Skip to content

Commit 02fcc50

Browse files
authored
Merge pull request #33 from josueJURE/minus-button
Minus button
2 parents c9ddbf3 + 744d4e5 commit 02fcc50

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

index.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
body {
1414
height: 100vh;
1515
width: 100vw;
16-
border: red solid 1px;
1716
display: flex;
1817
justify-content: center;
1918
align-items: center;

index.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const slidingPart = document.querySelector(".sliding-part");
66
const computationHistoryParent = document.querySelector(".computation-history-parent");
77
const operators = document.querySelectorAll("[data-operator]");
88
const clearHistoryBtn = document.querySelector(".clear-history-btn");
9+
let currentExpression
910

1011
clearHistoryBtn.addEventListener("click", () => {
1112
historyElement.innerHTML = "";
@@ -83,7 +84,10 @@ btns.forEach((btn) => {
8384
// forEach ends & functions creations begins
8485
function convertToPercentage(button) {
8586
if (button === "%") {
86-
screen.innerText = screen.innerText / 100;
87+
currentExpression = data.join('');
88+
currentExpression = currentExpression / 100;
89+
data = [currentExpression];
90+
screen.innerText = currentExpression;
8791
}
8892
}
8993

@@ -131,8 +135,11 @@ function deleteEverythingFromScreen(button) {
131135

132136
function toggleSign(button) {
133137
if (button === "minus") {
134-
let currentExpression = data.join("");
138+
console.log(data)
139+
currentExpression = data.join("");
140+
console.log(currentExpression)
135141
let reversedExpression = currentExpression.split("").join("");
142+
console.log(reversedExpression)
136143
let match = reversedExpression.match(/(\d+(\.\d+)?)|(\D+)/); // Match a number or non-digit
137144

138145
if (match) {

0 commit comments

Comments
 (0)