Created
January 21, 2022 02:01
-
-
Save johnakhilomen/262fa93bce7d0f9dfd05aa67e0b3ae8a 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(data) { | |
| var obj = {}; | |
| obj.getSum = function () { | |
| return calculateSum(data); | |
| }; | |
| obj.getAverage = function () { | |
| return calculateSum(data)/data.length; | |
| }; | |
| return obj; | |
| } | |
| var calc = Calculator([45,89,32,90,120]); | |
| console.log(calc.getSum(), calc.getAverage()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment