← Back to challenges

Mod 10 Algorithm

JavaScriptHardalgorithmslogicvalidation

Instructions

Create a function that takes a number 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.
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.