Skip to content

Instantly share code, notes, and snippets.

View littleomie's full-sized avatar
😁
Hakuna Matata

Romil Onin littleomie

😁
Hakuna Matata
  • Philippines
  • 06:36 (UTC +08:00)
View GitHub Profile
@littleomie
littleomie / checkdigit.js
Created August 31, 2023 07:38
Container Code Check Digit Calculation - ISO 6346
// let input = 'ECMU465749'; // 6
let input = 'GVTU300038'; // 9
function getCheckDigit(input) {
const char_map = {
'A': 10, 'B': 12, 'C': 13, 'D': 14, 'E': 15, 'F': 16, 'G': 17,
'H': 18, 'I': 19, 'J': 20, 'K': 21, 'L': 23, 'M': 24, 'N': 25,
'O': 26, 'P': 27, 'Q': 28, 'R': 29, 'S': 30, 'T': 31, 'U': 32,
'V': 34, 'W': 35, 'X': 36, 'Y': 37, 'Z': 38
};