Created
January 31, 2024 16:43
-
-
Save suhailgupta03/86b19e367027491a706623bd5cba285d to your computer and use it in GitHub Desktop.
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
function calculator(x, y) { | |
function add() { | |
return x + y; | |
} | |
function subtract() { | |
return x - y; | |
} | |
function multiply() { | |
return x * y; | |
} | |
return { | |
add: add, | |
subtract: subtract, | |
multiply: multiply | |
} | |
} | |
const calc = calculator(10, 5); | |
console.log(calc.add()); // 15 | |
console.log(calc.subtract()); // 5 | |
console.log(calc.multiply()); // 50 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment