loading...

re: Functional Programming in JavaScript VIEW POST

FULL DISCUSSION
 

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
}
 

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.

code of conduct - report abuse