Fixed the way in which the check digit is calculated to allow for the case where the checksum is exactly divisible by 10, to make the check digit 0. In the previous code the check digit was being returned as 10.
@@ -33,7 +33,7 @@
for (var i = 0; i < length - 1; i++) {
sum += parseInt(value.charAt(i)) * weight[i % 2];
}
- sum = 10 - sum % 10;
+ sum = (10 - sum % 10) % 10;
return (sum == value.charAt(length - 1));
};