Skip to content

Commit c8dcc85

Browse files
committed
feat(JS) create hasZeroDividedByZero()
1 parent 0c374aa commit c8dcc85

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

index.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,16 @@ btns.forEach((btn) => {
9494
? (display.innerText = "Math Error. Cannot divide by zero")
9595
: (display.innerText = outcome);
9696
}
97-
function zeroDivedByZero(display, outcome) {
98-
Number.isNaN(outcome)
99-
? (display.innerText = "0÷0 is an nvalid format press AC" )
100-
: (display.innerText = outcome)
97+
98+
function hasZeroDividedByZero(array) {
99+
for (let i = 0; i < array.length - 2; i++) {
100+
if (array[i] === "0" && array[i + 1] === "/" && array[i + 2] === "0") {
101+
return true;
102+
}
103+
}
104+
return false;
101105
}
106+
102107
function displayResult(array, outcome) {
103108
array = [];
104109
array.push(outcome);

0 commit comments

Comments
 (0)