Created
June 5, 2020 15:43
-
-
Save dinocarl/3c25a40873c6c1b67b4ada2841c4d815 to your computer and use it in GitHub Desktop.
Takes an array of numbers and returns their average, rounded to the thousands place
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
const toThsnds = compose( | |
multiply(1000), | |
Math.round, | |
multiply(1/1000) | |
); | |
const avgToThsnds = (arr) => compose( | |
toThsnds, | |
multiply(1/length(arr)), | |
reduce(add, 0) | |
)(arr); | |
avgToThsnds([100000, 110000, 150000]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment