Created
September 28, 2018 16:47
-
-
Save danlynn/6329aa6b3fcb17f18ce5b4cc302b5de3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function CalcCheckDigit(uncheckedUpc) { | |
let checkDigit = 0; | |
for (let i = 0; i < 11; i++) { | |
checkDigit += parseInt(uncheckedUpc.charAt(i)) * (i % 2 === 0 ? 7 : 9); | |
} | |
return checkDigit % 10; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment