Created
September 17, 2021 19:00
-
-
Save lydell/9b6692ec8246e1064ce423a521c1b497 to your computer and use it in GitHub Desktop.
Calculate the last digit of a Swedish personnummer – Note: don’t include `19` or `20` at the start!
This file contains hidden or 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
check = s => { let v = s.split("").map((c, i) => { let d = Number(c); let m = i % 2 === 0 ? d * 2 : d; return m > 9 ? m - 9 : m }).reduce((a, b) => a + b, 0); return (10 - (v % 10)) % 10} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment