Created
May 30, 2017 17:03
-
-
Save ar2zee/d5d20ac6c29cfba28f6ddfc8ed810716 to your computer and use it in GitHub Desktop.
example filter function wih array
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 animals = [ | |
{name : 'artur', food: 'potatoes'}, | |
{name : 'sergey', food: 'fries'}, | |
{name : 'anton', food: 'fries'}, | |
{name : 'petya', food: 'cream'}, | |
{name : 'oksana', food: 'chips'}, | |
{name : 'lesya', food: 'meat'}, | |
{name : 'julya', food: 'vegies'}, | |
{name : 'sasha', food: 'sour_cream'} | |
]; | |
var fries = animals.filter(function(animal) { | |
return animal.food === 'fries'; | |
}); | |
console.log(fries); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment