Skip to content

Instantly share code, notes, and snippets.

View Toheeb's full-sized avatar

Toheeb Ogunbiyi Toheeb

View GitHub Profile
@Toheeb
Toheeb / luhnAlgorithm.js
Created July 16, 2019 10:32
Here's the Luhn algorithm that takes an array of 16 digits to verify a valid credit card
const validateWithLuhn = (digits) => {
//console.log("digits are: ", digits);
let result = false;
if (/^\d{16}$/.test(digits.join("")) == false) {
//console.log('should be 16 hence false');
return false;
}
const step = 2;