[javascript] How to find first element of array matching a boolean condition in JavaScript?