I'm trying to use lodash 2.4.1 in order to know if there's at least one element within an array with true as its value.
So I decided to use lodash some or any function.
This is what my code looks like:
if ( _.some([lineup.reachesMaxForeignPlayers(), lineup.reachesBudgetLimit()], true) ) {
response.send(400, "La inclusión de este jugador no satisface las reglas del juego");
}
Which is never going inside the if block, even that first condition actually evaluates to true.
I got:
console.log(lineup.reachesMaxForeignPlayers());
console.log(lineup.reachesBudgetLimit());
Before the if block and I can actually see first statement evaluating to true.
What could it be failing?
I use lodash 2.4.1 as it's included Sails js dependency.
edit:
Actually, just using
_.some[docs] with no predicate defaults to identity:should work.
In addition to the other answers that suggest passing
Booleanas the predicate. You can also use: