Hello Codeacademy staff,
I finally encountered this exercise I was reading so much in the Get Help section of the forum, some feedback about it:
At step 3 when it states:
The calculations in the Luhn algorithm can be broken down as the following steps:
- Starting from the farthest digit to the right, AKA the check digit, iterate to the left.
- As you iterate to the left, every other digit is doubled (the check digit is not doubled). If the number is greater than
9
after doubling, subtract9
from its value.
I suggest to change it with:
The calculations in the Luhn algorithm can be broken down as the following steps:
- Either reverse the array and iterate normally from left to right or do not reverse the array but iterate from the right to the left.
- If the length of the original array is an odd number double the value of each digit that is positioned at an odd index, otherwise if the length of the original array is an even number, double the value of each digit that is positioned at an even index.
- If the number doubled is greater than
9
, subtract9
from its value.
Reason:
I find that the sentence âevery other digitâ can be easily misinterpreted, as by that it can be meant either the series of odd numbers or even numbers. So which to choose?
Well the purpose is to exclude the series that contain the last digit (Check Digit), however what is written in parenthesis: âcheck digit is not doubledâ imo does not address that. In fact, a possible confusing scenario is to double the series of numbers the check digit is part of, but not the check digit itself (check digit is not doubled indeed).
Itâs true however that thereâs the diagram linked at the end of the step which makes it very clear, if only a student would just click and open it.
Also, at step 7 when it states:
If youâd like to challenge yourself further, you could consider the following:
- Use different credit card numbers from a credit card number generator and validator site and test if your functions work for all types of credit cards.
The link indicated shows a table with the real conditions to use to verify if a card number is valid or not, however I have reason to suspect that some of those (VISA, VISA Electron, Maestro) are incorrect/incomplete. Maybe change it with a different link?
Cheers,