Mod 10 Algorithm

Published by Mubashir Hassan in

Create a function that takes a string of numbers and checks whethers the given number is a valid credit card number using Luhn Algorithm. The return value is boolean.

Examples

validCreditCard("4111111111111111") ➞ true
// Visa Card

validCreditCard("6451623895684318") ➞ false
// Not a valid credit card number.

validCreditCard("6451623895684318") ➞ false

Notes

  • American Express/VISA/Discover/Diner Club may be the credit card type.
  • Check the Resources for help.
Watch a quick demo on how Edabit works.