-
-
Save hedgejanuary/538b1f434f687705f392ae03dc089401 to your computer and use it in GitHub Desktop.
This is the modified codes to calculate average score.
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 averageScore(arr) { | |
var total = 0; | |
for (var i = 0; i < arr.length; i++) { | |
total += arr[i]; | |
} | |
return total / arr.length; | |
} | |
// Another solution: | |
var averageScore = function (arr) { | |
var total = 0; | |
arr.forEach(function (elem) { | |
total += elem | |
}); | |
return total / arr.length; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment