Skip to content

Instantly share code, notes, and snippets.

@vasanthk
Created July 24, 2015 21:42
Show Gist options
  • Save vasanthk/fbd7d8f13ab932d3e780 to your computer and use it in GitHub Desktop.
Save vasanthk/fbd7d8f13ab932d3e780 to your computer and use it in GitHub Desktop.
Using reduce(), instead of filter() and map()
tollCountries = phoneNumbers.reduce(function(countries, nums) {
if(!num.tollFree) {
countries.push({
// Push it in whatever format you need it.
})
}
return countries;
}, [])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment