Skip to content

Instantly share code, notes, and snippets.

@mistadikay
Last active August 29, 2015 14:07
Show Gist options
  • Save mistadikay/ac0dda627073fb96d82b to your computer and use it in GitHub Desktop.
Save mistadikay/ac0dda627073fb96d82b to your computer and use it in GitHub Desktop.
function checkControlSumPhysical(value){
var code = value.split(''),
x;
x = code[0] * (-1) + code[1] * 5 + code[2] * 7 + code[3] * 9 + code[4] * 4 + code[5] * 6 + code[6] * 10 + code[7] * 5 + code[8] * 7;
if (x % 11 === 10){
x = (x % 11) % 10;
} else{
x = x - (11 * Math.floor(x / 11));
}
return +code[9] === x;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment