Last active
August 17, 2018 10:08
-
-
Save ShaileshPrajapati-BTC/7febe85d6d49ecf9a098635088d68c8f to your computer and use it in GitHub Desktop.
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
| const animals = [ | |
| { | |
| "name": "cat", | |
| "size": "small", | |
| "weight": 5 | |
| }, | |
| { | |
| "name": "dog", | |
| "size": "small", | |
| "weight": 10 | |
| }, | |
| { | |
| "name": "lion", | |
| "size": "medium", | |
| "weight": 150 | |
| }, | |
| { | |
| "name": "elephant", | |
| "size": "big", | |
| "weight": 5000 | |
| } | |
| ] | |
| //Map Method | |
| let animal_names = animals.map((animal, index, animals) => { | |
| return animal.name | |
| }) | |
| console.log(animal_names) | |
| ["cat", "dog", "lion", "elephant"] | |
| // Filter Method | |
| // Ffind the animals whos size is small | |
| let small_animals = animals.filter((animal) => { | |
| return animal.size === "small" | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment