DEV Community


Discussion on: Functional Programming in JavaScript

vladimirgal1012 profile image
Vladimir Gal

Instead of looping we could use find too right ? We really don't like to use for/while etc unless we have to

const anyMatch = (list,predicate) => {
    return list.find(item => predicate(item)) != null
hunter profile image
Hunter Henrichsen Author

We could, but for someone who is not familiar with functional programming it's a little strange. We could also do this:

const anyMatch = (list, predicate) => list.some(predicate);

The point is to illustrate how this would work without applying functional programming to everything in order to build some understanding using familiar constructs.