Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
var dob=800101;
var gen=6;
var nin = ''+dob + gen +
Math.floor(Math.random()*10) +
Math.floor(Math.random()*10) +
Math.floor(Math.random()*10) +
Math.floor(Math.random()*2) +
Math.floor(Math.random()*10);
var sumEven = 0;
var sumOdd = 0;
var even = false;
for(i=0; i<12; i++) {
if(!even) {
sumOdd += parseInt(nin.charAt(i));
} else {
var doubleEven = 2*parseInt(nin.charAt(i));
sumEven += Math.floor(doubleEven/10)+(doubleEven % 10);
}
even = !even
}
var total = sumOdd + sumEven;
var check = (10 - (total % 10)) % 10;
fullnin = nin+check;
console.log(fullnin);
// this.page().replaceText(element, fullnin);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.