Last active
October 8, 2018 17:55
-
-
Save farynaio/c01fc5027d7251e18177f8cfacd01026 to your computer and use it in GitHub Desktop.
Javascript Object Discriminator filter
This file contains hidden or 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
| function discriminator(data) { | |
| if (!data) { | |
| return null; | |
| } | |
| return data.filter(function(item) { | |
| return item.age >= 30 && item.age <= 40; | |
| }); | |
| } | |
| function Person(name, age, gender) { | |
| this.name = name; | |
| this.age = age; | |
| this.gender = gender; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment