Implementation of the Luhn 10 algorithm to check validity of credit card numbers. See http://en.wikipedia.org/wiki/Luhn_algorithm for details on the algorithm.
var validCreditCard = function(a,b,c,d,e){for(d=+a[b=a.length-1],e=0;b--;)c=+a[b],d+=++e%2?2*c%10+(c>4):c;return!(d%10)};
validCreditCard('378282246310005'); //=> true
validCreditCard('378282246310006'); //=> false
// some numbers to test with
// 378282246310005 371449635398431 378734493671000
// 30569309025904 38520000023237 6011111111111117
// 6011000990139424 5555555555554444 5105105105105100
// 4111111111111111 4012888888881881 4222222222222
I'm pretty sure this can be further shortened, if anyone wants to code golf!