Skip to content

Instantly share code, notes, and snippets.

@JoaoCnh
Created February 14, 2018 11:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save JoaoCnh/1bf8ad1f7c627de5085ed950a0e252e5 to your computer and use it in GitHub Desktop.
Save JoaoCnh/1bf8ad1f7c627de5085ed950a0e252e5 to your computer and use it in GitHub Desktop.
Filter example 1
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