Created
July 23, 2014 08:33
-
-
Save yemrekeskin/2ad4a874bbef87dd139b to your computer and use it in GitHub Desktop.
Random Turkish Identification Number Generator with javascript
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
<!-- | |
Random Turkish Identification Number Generator | |
--> | |
<!DOCTYPE html> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<title></title> | |
</head> | |
<body> | |
<p id="tc"></p> | |
<script type="text/javascript"> | |
var a = "" + Math.floor(900000001 * Math.random() + 1e8), | |
b = a.split("").map(function (t) { | |
return parseInt(t, 10) | |
}), | |
c = b[0] + b[2] + b[4] + b[6] + b[8], | |
d = b[1] + b[3] + b[5] + b[7], | |
e = (7 * c - d) % 10; | |
document.getElementById("tc").textContent = a + ("" + e) + ("" + (d + c + e) % 10) | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment