Created
January 11, 2022 08:21
-
-
Save apnerve/12a89f712e6fe2c95849166150435444 to your computer and use it in GitHub Desktop.
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
function average(x, n=1) { | |
return function(y) { | |
if(y) { | |
n++ | |
return average(x+y, n) | |
} | |
return x/n | |
} | |
} | |
// const average = (x, n = 1) => y => y? average(x+y,++n): x/n |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment