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.
Well, this solution is wrong, yes.. But actually the year 2000 IS a leap year, because it is multiple of 400..
;)
It's a compact way to round a number without without needing to check for negatives and do Math.ceil/floor accordingly. ~~ is clever and useful but not intuitive :) http://stackoverflow.com/questions/4055633/what-does-do-in-javascript has a good writeup of how it works.
Please provide more detailed description of the task and some example test cases as well.
Thanks :-)
See here: http://jsfiddle.net/J3Spt/
Maybe it's not much shorter, but at least it's algoritmic :-)
If year is e.g. 2000 (non-leap), this solution will return incorrect result - true, I think :(
toLowerCase() is useful, but the "charCodeAt()" cannot return a prime number.Any other way to shorten the length?
@ca6age:
var handled = ending.replace(/[.+]/g, '\$&');
return new RegExp(handled + "$", "i").test(str);
:-) You could replace your function num with:
num_code_of_x = x.toLowerCase().charCodeAt(0);
Same here :(
Okay, I added the Test info in comments like most other katas do. That is what you were asking me to do, right?
Please provide Test object (or info that it's present) for user's own test cases
Will not work for test cases where number < 0, I think.
What is purpose of "~~" in this case?
Wow, really elegant solution :)