Validate a Credit Card Number with Functional JavaScript

Ben Lovy on November 03, 2019

Dolla Dolla Bill, Y'all Credit card companies are responsible for a high volume of highly sensitive global network traffic per minute wi... [Read Full]
markdown guide

I always thought credit card numbers were mostly just sorcery.

Thanks for demystifying it!


Thanks for the great post explaining how to validate credit card numbers programmatically.

If you prefer a web-based tool for validating credit card numbers, you can use Credit Card Validator. The result will be displayed instantly as well as the card type such as American Express, MasterCard, or VISA.

Of course, credit card numbers are very sensitive data, so this tool completely works offline on the browser. I hope it's useful.


You can reference the end of an array by using negative integers.
Instead of .slice(0, len - 1) you can do .slice(0, -1)


Ooh, thanks! Much nicer. JS is definitely not in my muscle memory yet.


Great article - fascinating on a good few levels.
Thanks for sharing!

Some comments have been hidden by the post's author - find out more

code of conduct - report abuse