-
-
Save AgtLucas/8e7ffbdcf5875f0061c263aef1b988a0 to your computer and use it in GitHub Desktop.
[JS] Using reduce to calculate average
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
var scores = [1, 4, 6, 8]; | |
var result = scores.reduce((total, score) => total + score) / scores.length; | |
console.log(result); // 4.75 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment