Created
January 6, 2014 00:45
-
-
Save jonasbits/8276285 to your computer and use it in GitHub Desktop.
in sweden everybody have a number, and that number have a checkdigit at the end that is based on http://en.wikipedia.org/wiki/Luhn_algorithm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var luhn10 = 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===0); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Found the code at http://rosettacode.org/wiki/Luhn_test_of_credit_card_numbers#JavaScript