// based off of Daily Coding Challenge #33
// print the running average
// Example: [2,1,3] prints...
// 2 (2/1=2)
// 1.5 (2+1=3, 3/2=1.5)
// 2 (2+1+3=6, 6/3=2)
function doit(ary){
for(var xint = 0;xint < ary.length;xint++){
var total = ary[0];
for(var yint = 1;yint < (xint+1);yint++){
total += ary[yint];
}
console.log(total / (xint+1));
}
}
doit([2,1,3]);
Sunday, March 26, 2023
Coding Challenge #33
Subscribe to:
Post Comments (Atom)
Coding Challenge #54 C++ int to std::string (no stringstream or to_string())
Gets a string from an integer (ejemplo gratis: 123 -> "123") Wanted to come up with my own function for this like 10 years ago ...
-
I NEEDS MY JAVASCRIPT PLEASE :) Open txtcode .txt Save as .gct Please click the blue cheat code title to activate it, a...
-
Naruto Personality Quiz Please enable javascript ☯ Which Naruto Character Are You?
-
Useful for extensions that want to prevent event listeners from being attached or modify prototypes or functions, generally to defeat click...
No comments:
Post a Comment