I have a task on Codecademy to create a function that takes an array of arrays and compares the first index of each array to another array with 4 indexes. Basically, I have a group of credit card numbers and I am looking at the first digit of each number and returning the company that sent the card based on the first number.
I chose to destruct the array like this
const cardCompanies = [3,4,5,6] = ['Amex','Visa','Mastercard','Discover'] While comparing them with these
[ [ 3, 7, 1, 6, 1, 2, 0, 1, 9, 9, 8, 5, 2, 3, 6 ], [ 4, 5, 3, 2, 7, 7, 8, 7, 7, 1, 0, 9, 1, 7, 9, 5 ], [ 5, 7, 9, 5, 5, 9, 3, 3, 9, 2, 1, 3, 4, 6, 4, 3 ], [ 3, 7, 5, 7, 9, 6, 0, 8, 4, 4, 5, 9, 9, 1, 4 ], [ 6, 0, 1, 1, 1, 2, 7, 9, 6, 1, 7, 7, 7, 9, 3, 5 ], [ 5, 3, 8, 2, 0, 1, 9, 7, 7, 2, 8, 8, 3, 8, 5, 4 ], [ 3, 4, 4, 8, 0, 1, 9, 6, 8, 3, 0, 5, 4, 1, 4 ], [ 6, 0, 1, 1, 3, 7, 7, 0, 2, 0, 9, 6, 2, 6, 5, 6, 2, 0, 3 ], [ 4, 9, 2, 9, 8, 7, 7, 1, 6, 9, 2, 1, 7, 0, 9, 3 ] ] The function, in the end, is supposed to return either the card company or 'Company not found'.
Thank you ahead of time for all advice. I enjoy working through this kind of problem.
https://stackoverflow.com/questions/67249349/should-i-destruct-an-array-to-compare-it-with-the-first-index-of-another-array April 25, 2021 at 10:58AM
没有评论:
发表评论