Last active
January 26, 2016 07:44
-
-
Save baybatu/a07593b73d464071b810 to your computer and use it in GitHub Desktop.
Parses credit card number with 16 characters into groups including 4 characters.
This file contains 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
/* | |
* Example usage: parseCreditCard('1234567890123456') -> [ '1234', '5678', '9012', '3456' ] | |
*/ | |
function parseCreditCard(cardNumber) { | |
return cardNumber.match(/.{1,4}/g); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment