Search code examples
javascriptlodash

Lodash overSome only applying first predicate


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']

Solution

  • 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.