/Credit_Card_Validator

Creating a credit card validator to practice using JS and testing in MD.

Primary LanguageJavaScript

Describe cardValid()

Test #1: "It will return a statement if the input is blank." Code: let textInput = "" cardValid(textInput) Expected Output: "Please enter a valid credit card number."

Test #2: "It will return a statement if the input isn't atleast 15 characters." Code: let textInput = "12341234" cardValid(textInput) Expected Output: "Please enter a valid credit card number."

Test #3: "It will return a statement if the input is at most 16 characters." Code: let textInput = "12341234123412341" cardValid(textInput) Expected Output: "Please enter a valid credit card number."

Test #4: "It will return the number with every other digit doubled" Code: let textInput = "1234123412341234" cardValid(textInput) Expected Output: "143143814381438."

Test #5: "It will return the sum of both digits if the number is >= 10." Code: let textInput = "1234567890123456" cardValid(textInput) Expected Output: "1438537790143853"

Test #5: "It will return not valid if the sum of all digits does not end in a zero" Code: let textInput = "1234567890123456" cardValid(textInput) Expected Output: "This credit card is not valid"

Describe cardCompany()

Test #1: "It will return American Express if the card begins with 34 or 37." Code: let textInput = "37020808604356" cardCompany(textInput) Expected Output: "American Express"

Test #2: "It will return Visa if the card begins with 4." Code: let textInput = "47020808604356" cardCompany(textInput) Expected Output: "Visa"

Test #3: "It will return Mastercard if the card begins with 5." Code: let textInput = "57020808604356" cardCompany(textInput) Expected Output: "Mastercard"

Test #4: "It will return Discover if the card begins with 6." Code: let textInput = "67020808604356" cardCompany(textInput) Expected Output: "Discover"

Test #5: "It will include the length of their credit card if its valid." Code: let textInput = "340208086043562" cardValid(textInput) Expected Output: American Express: 15