Created
November 25, 2019 04:07
-
-
Save hlfbt/def2693765a7d5683567f91219ab6261 to your computer and use it in GitHub Desktop.
Convert Nintendo friend codes to plain old integers, for whatever reason you might want to do that anyway
This file contains 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
function fc2int(fc) { | |
const codes = '0123456789ABCDEFGHJKLMNPQRSTUVWXY'; | |
fc = fc.toUpperCase().match(new RegExp(`[${codes}]`, 'g')); | |
return -1 + fc | |
.map((a, i) => (codes.indexOf(a) + 1) * Math.pow(codes.length - 1, i)) | |
.reduce((a, b) => a + b); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment