MCPcopy Index your code
hub / github.com/RandomAPI/Randomuser.me-Node / checkDigit

Function checkDigit

api/1.4/data/NO/inject.js:15–23  ·  view source on GitHub ↗
(staticSequence, input)

Source from the content-addressed store, hash-verified

13
14 const calculateCheckDigits = (tenDigits) => {
15 const checkDigit = (staticSequence, input) => {
16 input = input.split('').map(Number);
17 let productSum = staticSequence.reduce((acc, value, index) => {
18 return acc + value * input[index];
19 }, 0);
20
21 const sumMod11 = productSum % 11;
22 return (sumMod11 === 0 ? '0' : (11 - sumMod11));
23 };
24 const staticSequenceFirstCheckDigit = [3, 7, 6, 1, 8, 9, 4, 5, 2];
25 const staticSequenceSecondCheckDigit = [5, 4, 3, 2, 7, 6, 5, 4, 3, 2];
26

Callers 1

calculateCheckDigitsFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected