Skip to content

Instantly share code, notes, and snippets.

@andrei-cacio
Created July 14, 2018 08:17
Show Gist options
  • Save andrei-cacio/9ea789da83b7d99d7227cb0d94163f96 to your computer and use it in GitHub Desktop.
Save andrei-cacio/9ea789da83b7d99d7227cb0d94163f96 to your computer and use it in GitHub Desktop.
Sum of args refactored with map, filter and reduce
process.argv
.filter(function(item){ return !Number.isNaN(Number(item)); })
.map(function(item){ return Number(item); })
.reduce(function(acc, item){ return acc + item }, 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment