Skip to content

Commit

Permalink
Added fix for birth numbers with mod11 check == 0, which would have c…
Browse files Browse the repository at this point in the history
…ontrol digit 11 and not 0 which is correct.
  • Loading branch information
iorg1 committed Mar 1, 2013
1 parent f728a0c commit 70450f3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions noValidation.js
Expand Up @@ -50,8 +50,10 @@ module.exports = (function(){
return sum;
};

var checksum1 = 11 - (sum(birthNumber, [3, 7, 6, 1, 8, 9, 4, 5, 2]) % 11);
var checksum2 = 11 - (sum(birthNumber, [5, 4, 3, 2, 7, 6, 5, 4, 3, 2]) % 11);
var checksum1 = 11 - (_sum(birthNumber, [3, 7, 6, 1, 8, 9, 4, 5, 2]) % 11);
if (checksum1 === 11) checksum1 = 0;
var checksum2 = 11 - (_sum(birthNumber, [5, 4, 3, 2, 7, 6, 5, 4, 3, 2]) % 11);
if (checksum2 === 11) checksum2 = 0;
return checksum1 === parseInt(birthNumber.charAt(9), 10)
&& checksum2 === parseInt(birthNumber.charAt(10), 10);
};
Expand Down

0 comments on commit 70450f3

Please sign in to comment.