Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
I'm shocked that over twice as many users solved this with the ternary than without.
what's the last 10 for ?
why u all reversing array?LOL
You're right, I've just refactored my solution. Thanks !
Why are you doing a terenary when it already returns a boolean?
Normally I'd say yes, giving
parseInt
a radix of 10 is best form. However, you really only have to worry about specifying a radix if the string could possibly have a leading"0x"
or"0"
. E.g.Both of those are impossible in this case: we know that the string is a number in string form and the digits are sorted in descending order, so it can't possibly begin with
"0x"
or"0"
(unless the number is 0, and then the radix is irrelevant).I prefer
+n
anyway in most cases, because you can test that the result isn'tNaN
.parseInt
andparseFloat
provide no error handling whatsoever.