Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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 :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading