Created
April 18, 2018 11:55
-
-
Save molda/c95dcc07264a32dd4d9a4b94fd84ee64 to your computer and use it in GitHub Desktop.
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
function everage(each) { | |
var count = 0; | |
var result = []; | |
var len = arr.length; | |
if (!each) { | |
var val = 0; | |
for (var i = 0; i < len; i++) { | |
val += arr[i]; | |
} | |
return val / len; | |
} | |
for (var i = 0; i < len; i += each) { | |
var val = 0; | |
var temparr = arr.slice(i, i + each); | |
for (var j = 0; j < temparr.length; j++) { | |
val += temparr[j]; | |
} | |
result.push(val / temparr.length); | |
} | |
return result; | |
} | |
var arr = []; | |
for (var i = 0; i < 100; i++) arr.push(i); | |
everage(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment