Created
March 2, 2022 21:57
-
-
Save thenanosoft/468048ec96e8f32b82437e3fbcbcca1a to your computer and use it in GitHub Desktop.
Create calculator calling different operators with functions in javascript
This file contains 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
// Create calculator calling different operators with functions in javascript | |
function pow(value0, value1) { | |
return Math.pow(value0, value1); | |
} | |
function mod(value0, value1) { | |
return value0 % value1; | |
} | |
function div(value0, value1) { | |
return value0 / value1; | |
} | |
function mul(value0, value1) { | |
return value0 * value1; | |
} | |
function add(value0, value1) { | |
return value0 + value1; | |
} | |
function subtract(value0, value1) { | |
return value0 - value1; | |
} | |
function calculator(value0, value1, operator) { | |
return operator(value0, value1); | |
} | |
console.log(calculator(2,5,mod)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment