Write a function cardType(cardNumber) that finds the card type from the first four digits of a card number.
cardNumber is a string of exactly 16 digits, without spaces. It can start with 0.16, return 'Visa', otherwise return 'Master'.'Visa' or 'Master', with a capital first letter.Why a string: a 16-digit card number does not always fit exactly into a JavaScript number. For example, Number('9999999999999999') gives 10000000000000000.
cardType('4552720412345678')Returns 'Visa'
cardType('5100123412341234')Returns 'Master'
cardType('0790100000000000')Returns 'Visa'
Asked at Luxoft · Source
cardType('4552720412345678')'Visa'cardType('5100123412341234')'Master'cardType('0790100000000000')'Visa'Hidden tests run on Submit.