Last active
August 29, 2015 14:05
-
-
Save macikokoro/153b981265474e6ee694 to your computer and use it in GitHub Desktop.
Finding the mean with javaScript
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
//Find mean | |
var numArray = [2, 4, 4, 6, 8, 10]; | |
var mean = 0; | |
for (var i = 0; i < numArray.length; i++) { | |
mean += numArray[i]; | |
} | |
//logs the length of the array | |
console.log(numArray.length); | |
//logs the result of adding the intengers in the array | |
console.log(mean); | |
//logs the result mean of the array | |
console.log(mean/numArray.length); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment