Home > database >  Lodash overSome only applying first predicate
Lodash overSome only applying first predicate

Time:09-15

I want to include both "zip" and "country", but somehow only "zip" is included. What am I doing wrong?

const arr = ['county', 'zip', 'town'];
const func = filter(overSome(equals('zip'), equals('county')));
const ans = func(arr);
console.log(ans);
// Output: ['zip']

CodePudding user response:

overSome takes 1 argument: an array of predicates. Currently you are providing multiple arguments. Change that line to:

const func = filter(overSome([equals('zip'), equals('county')]));

Only your "zip" matches because that's the one argument lodash was looking for.

  • Related