Skip to content

Instantly share code, notes, and snippets.

@KarlHerler
Created August 24, 2011 07:19
Show Gist options
  • Save KarlHerler/1167472 to your computer and use it in GitHub Desktop.
Save KarlHerler/1167472 to your computer and use it in GitHub Desktop.
alculating finnish banking reference numbers (Viitenumerot) in javascript, courtesy of jocke.
function refnr(source) {
var chk = 0;
var weights = [7,3,1];
for( var i=0; i<source.length; i++ ) {
chk += (source[source.length-i-1]-'0')*weights[i%3];
}
return source+((10-(chk%10))%10);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment