How to implement the check digit algorithm specified in ISO 6346 Freight containers — Coding, identification and marking?
Question posted in Javascript
A very good W3school tutorial can be found here.
A very good W3school tutorial can be found here.
2
Answers
Implementation in JavaScript:
Usage:
Here,
check
is the 11th character extracted from the string, which is the check digit.calculation
is the check digit calculated from the first 10 characters in the string. If these two match, then the string is valid.JSFiddle
Alternatively, using map and reduce.
(Where
csc
is a valid 11 digit string'ABCD1234560'
.)JSFiddle