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.
From the official Documentation: retired.
It's retired, nothing left to do with it. Why open an issue on an already retired kata? Closing.
this Kata has been retired because there is an issue with leading zeros.
Eg. maxNumber(0010) should output 1000 right??
Well the browsers automatically treat such number as binary and convert it to: 8 (decimal number), so our code also will output 8.
In order to resolve this, in case we have leading zeros we should use .toString(2) , but how to check if our input number has leading zeros??
apart from 'Best Practices' and 'Clever', there should also be 'Quantum' vote
yes, match returns an array, even if there is only one match, so we have to point to eg the first item [0]
'----123--45--'.match(/(\d+)/)[0] //123
otherwise we will get an array of two, with the same item:
'----123--45--'.match(/(\d+)/) // [123, 123]
The problem is with passing an argument with leading zeros which browsers treat as octal number. Eg. 015 is beeing converted to 13 which throws our code off. If there was some way to test whether our input have leading zeros, then in such case we might convert it to decimal eg. 015.toString('8') gives 15, so 1+5 = 6.