I'm looking for a neat way to do this:
return func(arr) >= 0 ? func(arr) : arr.length;
Calling func(arr)
does not modify anything, so the above works fine.
But I would still like to avoid executing func(arr)
twice.
Is there a neat way to achieve that in JavaScript?