Skip to content

Instantly share code, notes, and snippets.

@pacdiv
Created August 9, 2018 18:05
Show Gist options
  • Select an option

  • Save pacdiv/d7a759075ea1ac025a909282b218be2f to your computer and use it in GitHub Desktop.

Select an option

Save pacdiv/d7a759075ea1ac025a909282b218be2f to your computer and use it in GitHub Desktop.
'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