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.
Quite easily. I've never had an interview question about type coercion.
How would they go about getting a job as a developer if they didn't know about implicit type coercion?
"cheating" in this context is a joke. Of course I'd use a built in method.
magic
This comment is hidden because it contains spoiler information about the solution
num+''
was my first thought, and as you say it's legit... but I went withtoString()
for readability - ie. you can be sure everyone on your team can work out what "toString" is doing, but the other way requires slightly more knowledge of implicit type coercion. To say nothing of this solution... impressive, but your team mates may not appreciate it ;)Thanks for quick reply
In addition to what laoris said JavaScript does not use the Indian Calendar natively. So if you are writing your own tests using values from the web sites calendar rather than the day JavaScript returns you will never pass the tests with an Indian calndar driven test.
The values I use in the hard-coded tests use the values JavaScript returns by default, therefor it doesn't matter which country you are doing the Kata from as JavaScript sticks to it's native clendar type and always return the same day for a date no matter where you are (unless you intentionally convert it).
The idea of the Kata is to get the person to deal with the JavaScript quirks which turn the 72 into 1972 unless you do what you have to do to pass the Kata.
The point of this kata is to deal with first-century dates. So when a test says year "72", it doesn't mean 1972.
17-1-72 is Monday, please correct your test-case, as i am unable to complete the kata because of it.
http://www.timeanddate.com/calendar/?year=1972&country=35
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Ooooooh... I see. I know I must've been missing something ;P Thanks.
Yeah, you have missed app. 1900 years :-)
It seems the tests are just straight-up wrong. Looking at the example test fixture, "19-11-0017" should actually be Monday, and "5-7-53" should be Sunday. You can see this by doing something like
new Date(17,11-1,19).toLocaleString()
, which gives "Mon Nov 19 1917 00:00:00 GMT+0000 (UTC)" for me. Is there something I'm missing here?Loading more items...