aboutsummaryrefslogtreecommitdiff
path: root/challenge-122/stuart-little/node/ch-1.js
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-122/stuart-little/node/ch-1.js')
-rwxr-xr-xchallenge-122/stuart-little/node/ch-1.js8
1 files changed, 8 insertions, 0 deletions
diff --git a/challenge-122/stuart-little/node/ch-1.js b/challenge-122/stuart-little/node/ch-1.js
new file mode 100755
index 0000000000..20b3e377e3
--- /dev/null
+++ b/challenge-122/stuart-little/node/ch-1.js
@@ -0,0 +1,8 @@
+#!/usr/bin/env node
+
+// run <script> <space-separated numbers>
+
+console.log(
+ process.argv.slice(2).map(x => parseFloat(x)).reduce(
+ (acc,val,ix) => acc.concat((acc[acc.length-1]*ix+val)/(ix+1)),[0,]).slice(1)
+)