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.
Correct, it'll fail.
The author should have added that to the list of test-cases earlier (perhaps to intentionally escape weird inputs).
It's not hard to either use
endsWith
(if available) or implement a trivial linear (O(n)) solution that scans each character from the end of the string.The latter could be then optimized by splitting the ending into two halves and checking first and last characters for each half (that way it'll give negative response faster than a linear solution).
Just for your information, 'abc' and 'c' are both incorrect string literals since they should end with an additional apostrophe.
dibley1973, yes, it make sense to apply indentation for inner query.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Clean, nice and perfect. Bravo.
Maybe the best way is to sort gifts queue when you call the 'addGift' method?
In such a way you can just shift the first element in the queue and return it's name when calling a 'buyGift' method/
Using function's activation object in order to get and set the 'secret' value. Clever indeed.
For what purpose you instantiate an instance of some class? And if you realy want to use Object oriented approach, then why don't you use a prototype in order to contain all the instance methods there?