luhnCheck
Implementation of the Luhn Algorithm used to validate a variety of identification numbers, such as credit card numbers, IMEI numbers, National Provider Identifier numbers etc.
- Use
String.prototype.split(''),Array.prototype.reverse()andArray.prototype.map()in combination withparseInt()to obtain an array of digits. - Use
Array.prototype.splice(0, 1)to obtain the last digit. - Use
Array.prototype.reduce()to implement the Luhn Algorithm. - Return
trueifsumis divisible by10,falseotherwise.