Implementation of the Lunh algorithm in Javascript
npm install @recodable/lunhSimple implementation of the Lunh Algorithm which can be useful to check credit card 💳 before processing.
``npm i @recodable/lunh`
or
`yarn add @recodable/lunh`
`jsconst { lunh } = require('@recodable/lunh');
import { lunh } from '@recodable/lunh';
// or for Node.js module
lunh('4242424242424242'); // returns true as "4242424242424242" is valid credit card
lunh('4242424242424241'); // returns false for invalid credit card
lunh('4242 4242 4242 4242'); // we also accept spaces
lunh('4242-4242-4242-4242'); // and dashes
lunh('424242424242hello'); // returns false if anything else is pass to the function
``
Inspired by DiegoSalazar