Created
July 14, 2018 08:17
-
-
Save andrei-cacio/9ea789da83b7d99d7227cb0d94163f96 to your computer and use it in GitHub Desktop.
Sum of args refactored with map, filter and reduce
This file contains 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
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