Skip to content

Instantly share code, notes, and snippets.

@kutyel
Created September 20, 2016 17:08
Show Gist options
  • Save kutyel/2221aabf8cb98fef8178b409d55d2dba to your computer and use it in GitHub Desktop.
Save kutyel/2221aabf8cb98fef8178b409d55d2dba to your computer and use it in GitHub Desktop.
Average of numbers (JavaScript)
averages = n => n ? n.reduce((x,y,i,z) => i < z.length - 1 ? x.concat((y + z[i + 1] || 0) / 2) : x, []) : [];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment