Created
August 9, 2018 18:05
-
-
Save pacdiv/d7a759075ea1ac025a909282b218be2f 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
| 'use strict'; | |
| const characters = [ | |
| { id: 1, name: 'ironman', env: 'marvel' }, | |
| { id: 2, name: 'black_widow', env: 'marvel' }, | |
| { id: 3, name: 'wonder_woman', env: 'dc_comics' }, | |
| ]; | |
| function hasCharacterFrom(env) { | |
| return character => character.env === env; | |
| } | |
| console.log(characters.find(hasCharacterFrom('marvel'))); | |
| // { id: 1, name: 'ironman', env: 'marvel' } | |
| console.log(characters.some(hasCharacterFrom('marvel'))); | |
| // true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment