Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save KinyuaMwaniki/2e8424d6ecc8c8253897d99c12d4f41b to your computer and use it in GitHub Desktop.

Select an option

Save KinyuaMwaniki/2e8424d6ecc8c8253897d99c12d4f41b to your computer and use it in GitHub Desktop.
Filter Arrays with filter
var oldArray = [1,2,3,4,5,6,7,8,9,10];
// We declare our newArray which holds the .filter method, filter proceeds to grab each element in our array,
// and pass them as arguments to the function which returns our result.
var newArray = oldArray.filter( function(a) {
return a < 6;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment