Special Calculator Function with Javascript

Viewed 21

I am trying to build a calculator using tutorials online as I am learning javascript. I wanted to ask if there is a way to add custom/special function to a calculator built using javascript.

Let's say just for a specific calculation like (14 * 14) I want the calculator to redirect me to another website as some sort of a guessing game.

Link to tutorial's javascript file: https://github.com/WebDevSimplified/Vanilla-JavaScript-Calculator/blob/master/script.js

Any help would be greatly appreciated. Thank you.

1 Answers

Change

      case '*':
        computation = prev * current
        break

to

      case '*':
        if (prev == 14 && current == 14) {
            window.location = "URL of guessing game";
        } else {
            computation = prev * current
        }
        break
Related