Last active
October 8, 2017 16:31
-
-
Save the-creature/d7ab3941b0f75638b9884730a36f6287 to your computer and use it in GitHub Desktop.
ES6 filter and map basic
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
const numbers = [1,2,3,4,5,6,7,8,9,10]; | |
const getEvenNumbers = numbers.filter(n => n % 2 === 0); | |
getEvenNumbers // [2, 4, 6, 8, 10] | |
const double = getEvenNumbers.map(n => n * 2); | |
double // [4, 8, 12, 16, 20] | |
numbers // [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment