Last active
August 29, 2015 14:23
-
-
Save cillierburger/e182579181114ee47890 to your computer and use it in GitHub Desktop.
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
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