Created
October 24, 2014 19:55
-
-
Save ertugrulozcan/21e6d7fe6eeafde5a7cf to your computer and use it in GitHub Desktop.
RandomProjectGenerator - 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
<html> | |
<head> | |
<title> | |
JavaScript Test | |
</title> | |
</head> | |
<body> | |
<pre> | |
<script language="Javascript"> | |
var words = | |
{ | |
"TR" : | |
{ | |
"names" : ["isim1", "isim2", "isim3", "isim4", "isim5", "isim6", "isim7", "isim8", "isim9"], | |
"adjectives" : ["sifat1", "sifat2", "sifat3", "sifat4", "sifat5", "sifat6", "sifat7", "sifat8", "sifat9"] | |
}, | |
"EN" : | |
{ | |
"names" : ["name1", "name2", "name3", "name4", "name5", "name6", "name7", "name8", "name9"], | |
"adjectives" : ["adjective1", "adjective2", "adjective3", "adjective4", "adjective5", "adjective6", "adjective7", "adjective8", "adjective9"] | |
} | |
}; | |
function Random(maxRange) | |
{ | |
return Math.floor((Math.random() * maxRange) + 1); | |
} | |
function Generate(count, language) | |
{ | |
var list = []; | |
for (i = 0; i < count; i++) | |
{ | |
randName = Random(words[language]["names"].length - 1); | |
randAdjective = Random(words[language]["adjectives"].length - 1); | |
list.push(words[language]["names"][randName] + " " + words[language]["adjectives"][randAdjective]); | |
} | |
return list; | |
} | |
function GenerateAndPrint(count, language) | |
{ | |
var pairList = Generate(count, language); | |
for (i = 0; i < pairList.length; i++) | |
{ | |
document.writeln((i+1) + " : " + pairList[i]); | |
} | |
} | |
// Ornek | |
GenerateAndPrint(5, "EN"); | |
</script> | |
</pre> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment