Last active
November 28, 2018 13:44
-
-
Save Yago/6f08437b368918603b5e311144af25e9 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
class Calculator { | |
constructor(origin) { | |
this.origin = origin; | |
} | |
sum(...args) { | |
return args.reduce((acc, n) => typeof n === 'number' ? acc + n : acc, this.origin); | |
} | |
} | |
const Hal = new Calculator(31); | |
Hal.sum(7, 4); // return 42 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment