Skip to content

Commit d54a988

Browse files
committed
feat(JS) create convertToPercentage()
1 parent 8620baf commit d54a988

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

index.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ btns.forEach((btn) => {
2626

2727
handleNumberButton(buttonValue);
2828

29+
deteLastEntry(buttonValue);
30+
31+
convertToPercentage(buttonValue);
32+
2933
function userClicksOnEqualButton(button) {
3034
if (button === "=") {
3135
try {
@@ -84,26 +88,29 @@ btns.forEach((btn) => {
8488
array.push(outcome);
8589
}
8690

87-
if (buttonValue === "%") {
88-
screen.innerText = screen.innerText / 100;
89-
}
91+
9092

91-
deteLastEntry(buttonValue);
93+
9294
});
9395
});
9496

9597
// end of forEach() statement
9698

99+
function convertToPercentage(button) {
100+
if (button === "%") {
101+
screen.innerText = screen.innerText / 100;
102+
}
103+
}
104+
97105
function deteLastEntry(button) {
98-
if(button === "DE") {
106+
if (button === "DE") {
99107
let newArray = data.slice(0, -1);
100108
screen.innerText = newArray.join("");
101109
data = newArray;
102110
if (screen.innerText === "") {
103111
screen.innerText = 0;
104112
}
105113
}
106-
107114
}
108115

109116
function canUserAddDot(button) {

0 commit comments

Comments
 (0)