Last active
March 13, 2018 21:55
-
-
Save DavidMellul/60f891221473d98b869033e9c98feb7e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // 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