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