Untitled

mail@pastecode.io avatar
unknown
plain_text
3 years ago
406 B
2
Indexable
Never
// Luhn Check
var luhnChk = (function(arr) {
    return function(ccNum) {
        var
            len = ccNum.length,
            bit = 1,
            sum = 0,
            val;

        while (len) {
            val = parseInt(ccNum.charAt(--len), 10);
            sum += (bit ^= 1) ? arr[val] : val;
        }

        return sum && sum % 10 === 0;
    };
}([0, 2, 4, 6, 8, 1, 3, 5, 7, 9]));
// Luhn Check