Created
July 11, 2019 06:11
-
-
Save anushshukla/b339420bcd132daa3848ca1473f1e8c5 to your computer and use it in GitHub Desktop.
NodeJs Script for a Basic Calculator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const add = function(input1, input2) { | |
| return input1 + input2; | |
| } | |
| const subtract = function(input1, input2) { | |
| return input1 - input2; | |
| } | |
| const multiple = function(input1, input2) { | |
| return input1 * input2; | |
| } | |
| const divide = function(input1, input2) { | |
| return input1 / input2; | |
| } | |
| const compute = function(input1, operator, input2) { | |
| switch(operator) { | |
| case "+": return add(input1, input2); | |
| case "-": return subtract(input1, input2); | |
| case "*": return multiple(input1, input2); | |
| case "/": return divide(input1, input2); | |
| } | |
| } | |
| export default compute; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment