DEV Community

Discussion on: Question: Is this a terrible idea?

Collapse
 
sargalias profile image
Spyros Argalias • Edited

I don't see a big problem with it. If you and your team are happy, then by all means use anything :).

But since you're asking, I would personally name the function something like safeHasElements(array). The reasoning for this is because you (or someone new to the code) might expect atLeastOne to take an array only, and error if it gets null or undefined. But in functional programming, the word "safe" normally implies that things won't throw errors but fail silently instead, or in your case just return false / undefined.

Collapse
 
harleybl profile image
harleybl

Thanks, Spyros - I like your naming suggestion.