Skip to content

Challenge Prefilter JSON

Quincy Larson edited this page Aug 20, 2016 · 1 revision

Challenge Prefilter JSON

The filter() method creates a new array with all elements that pass the test implemented by the provided function.

So when you don't want to work with all the elements from the array then you can use filter.

Let's filter out the cat who's "id" key has a value of 1.

Here's the code to do this:

json = json.filter(function(val) {

  return(val.id !== 1);

});

More about filter:

Clone this wiki locally