/training-js-luhn

JavaScript training exercise to implement Luhn card number validator

Primary LanguageJavaScript

JavaScript Luhn Algorithm Training

About the algorithm

The Luhn algorithm or Luhn formula, also known as the "modulus 10" or "mod 10" algorithm, is a simple checksum formula used to validate a variety of identification numbers, such as credit card numbers, IMEI numbers, National Provider Identifier numbers in the US, and Canadian Social Insurance Numbers. It was created by IBM scientist Hans Peter Luhn and described in U.S. Patent No. 2,950,048, filed on January 6, 1954, and granted on August 23, 1960.

-- Wikipedia

There are many descriptions of Luhn algorithm in the Internet e.g. this one

What to do

Implement Luhn algorithm to check credit card numbers.

There is a big list of valid and invalid card numbers in tests folder that will be used to test the algorithm.

Write your code in src/index.js next to // TODO comment.

Setup

  1. Clone/Fork the repository
  2. Run npm install in repository root to install all required dependencies
  3. Run npm test to test your algorithm with test data
  4. Implement Luhn algorithm to pass all the tests

Prerequisites

  1. Basic understanding of programming
  2. Node.js installed on you machine
  3. Basic git skills to clone this repository