Skip to content

Instantly share code, notes, and snippets.

@DavidMellul
Last active March 13, 2018 21:55
Show Gist options
  • Select an option

  • Save DavidMellul/60f891221473d98b869033e9c98feb7e to your computer and use it in GitHub Desktop.

Select an option

Save DavidMellul/60f891221473d98b869033e9c98feb7e to your computer and use it in GitHub Desktop.
// Using ES6 arrow functions
// Returns true if all even numbers doubled from @numbers are above 5
function doubleEvenNumbers(numbers) {
return numbers
.filter(x => x % 2 == 0) // Odd numbers removed
.map(x => x*2) // Even numbers doubled
.every(x => x > 5); // Are they all above 5 ?
}
console.log(doubleEvenNumbers([3,4,5,6]))
// => True, because doubled array is [8,12]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment