getCheckCode(id)
Calculate the check digit (last digit) of an ID number.
Signature
typescript
function getCheckCode(id: string): string | nullParameters
| Parameter | Type | Description |
|---|---|---|
| id | string | ID number (first 17 digits) |
Returns
Returns the computed check digit (0-9 or X). Returns null if the input format is invalid.
Live Demo
Example
typescript
import { getCheckCode } from 'china-id-card'
getCheckCode('62292219780811849') // → '8'
getCheckCode('31000019810227632') // → '3'