Created
October 9, 2015 15:22
-
-
Save vlas-ilya/c73880a4993f78ce1d9e to your computer and use it in GitHub Desktop.
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 isValidCreditCard = function (xs) { | |
return xs.split('').reverse().map(function (elem, index, xs) { | |
return index % 2 ? (2 * elem < 9 ? 2 * elem : 2 * elem - 9) : Number(elem); | |
}).reduce(function(sum, elem) { return sum + elem }) % 10 == 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment