Created
September 25, 2019 17:30
-
-
Save niktariy/13c232dc222de7d962bee09fe08b438c to your computer and use it in GitHub Desktop.
Function overloading with arrow functions
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
const average = () => { | |
const length = arguments.length; | |
if (length == 0) return 0; | |
const numbers = Array.prototype.slice.call(arguments); | |
const sumReduceFn = function (a, b) { return a + Number(b) }; | |
return numbers.reduce(sumReduceFn, 0) / length; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment