DEV Community

Cover image for Validate a Credit Card Number with Functional JavaScript

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...
Collapse
 
jlhernandez profile image
Jose L. Hernández
Comment hidden by post author
Collapse
 
deciduously profile image
Ben Lovy

The intended takeaways here are checksums and the functional-style implemention - definitely not intended as an introduction to financial processing.

Collapse
 
jlhernandez profile image
Jose L. Hernández

Sure, that's why I think it is a bad topic for a tutorial.
The programming style is cool, but it would be better if you implemented another algorithm, something that could be used in a real world app, or at least warn the readers they should never get credit card numbers in their app (unless they are building a bank..)

Thread Thread
 
deciduously profile image
Ben Lovy

Fair point!

Collapse
 
rohansawant profile image
Rohan Sawant

I always thought credit card numbers were mostly just sorcery.

Thanks for demystifying it!

Collapse
 
emily-flias profile image
Emily Flias
Collapse
 
alexfinch profile image
Alex Finch • Edited
Comment hidden by post author
Collapse
 
vccgenerator profile image
VCCGenerator • Edited
Comment hidden by post author
Collapse
 
shortlonghair profile image
Short Hairstyle

The main advantage of the credit card generator is that it allows users to make use of the system even without the knowledge of the person using it. This way, a user will not be able to figure out whether the visa card generator is actually valid or not. Hence, people may end up spending more money on these fake generators than they actually have.

Collapse
 
poppybeck profile image
poppybeck • Edited

Hey Ben Lovy

Thanks for sharing information Validate a Credit Card or Debit Card Number with Functional JavaScript there are some sites on the internet which work with the Functional JavaScript one of the best examples is cardgenerators.org

Collapse
 
emnudge profile image
EmNudge

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

Collapse
 
deciduously profile image
Ben Lovy

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

Collapse
 
orighoprecious profile image
Origho Precious

Very nice article. kudos!

Collapse
 
bluebob profile image
bluebob

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

Collapse
 
portondr profile image
portondr
Comment hidden by post author

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