Skip to content

Instantly share code, notes, and snippets.

@C-Hodor
Last active May 6, 2021 14:49
Show Gist options
  • Select an option

  • Save C-Hodor/5a6822007e1be5aebbf447f40041bf82 to your computer and use it in GitHub Desktop.

Select an option

Save C-Hodor/5a6822007e1be5aebbf447f40041bf82 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