Created
February 14, 2018 11:03
-
-
Save JoaoCnh/1bf8ad1f7c627de5085ed950a0e252e5 to your computer and use it in GitHub Desktop.
Filter example 1
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
var numbers = [1,2,3,4,5,6,7,8,9,10]; | |
var evenNumbers = numbers.filter(function (num) { | |
return num % 2 === 0; | |
}); | |
// ES6 | |
const evenNumbers = numbers.filter(num => { | |
return num % 2 === 0 | |
}); | |
console.log(evenNumbers); // [2,4,6,8,10]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment