Simplicity, the ultimate sophistication.
Genius. From my humble perspective at least
better to do CONST value for 10, i done so, but think then more
If the requirements state "10 or more," then I think it is better to translate that language directly to code (i.e., "foo >= 10") rather than to a logical but inferred equivalent.
However obvious the inference might seem to you, it might not be so obvious to the maintenance developer who needs to understand how your code manages to fulfill (or, if he is fixing a defect, how it fails to fulfill) the requirements.
An obvious exception is when performance is an issue--but, then, only when performance is an active, demonstrable issue. (In this case, there is no performance advantage either way.)
I refactored the description and improved the tests so this should not be a problem. Marking resolved.
The only advantage is less code as you said.
In most cases, using if/else is recommanded for readability.
What is the advantage to using this ternary/conditional operator vs say an if/else aside from less code? Is there a practical advantage or more edge case?
Added a coffeescript translation!
i've updated the description to be more clear.
What about adding more random tests (e.g. repeating it 4-5 times)?
This comment is hidden because it contains spoiler information about the solution
Try again? Sometimes the testing environment just crashes/timeouts/whatever
Thanks! CoffeeScript looks like an interesting language :) Approved!