So I'm working on creating a name generator for New Horizons Island names to include on a website I'm making. I haven't finished the wordlist yet, so those are just presets. I want to modify this code to set a max character limit of 8 for the output, but am unsure how. I'd appreciate any help/suggestions, as I only know some HTML and no javascript.
<script type="text/javascript">
function generator(){
var wordlist1 = ["Cool","Masked","Bloody","Lame","Big","Stupid","Drunk","Rotten",
"Blue","Black","White","Red","Purple","Golden","Silver"];
var wordlist2 = ["Hamster","Moose","Lama","Duck","Bear","Eagle","Tiger",
"Rocket","Bullet","Knee","Foot","Hand"]
var randomNumber1 = parseInt(Math.random() * wordlist1.length);
var randomNumber2 = parseInt(Math.random() * wordlist2.length);
var name = wordlist1[randomNumber1] + " " + wordlist2[randomNumber2];
if(document.getElementById("result")){
document.getElementById("placeholder").removeChild(document.getElementById("result"));
}
var element = document.createElement("div");
element.setAttribute("id", "result");
element.appendChild(document.createTextNode(name));
document.getElementById("placeholder").appendChild(element);
}
</script>
function generator(){
var wordlist1 = ["Cool","Masked","Bloody","Lame","Big","Stupid","Drunk","Rotten",
"Blue","Black","White","Red","Purple","Golden","Silver"];
var wordlist2 = ["Hamster","Moose","Lama","Duck","Bear","Eagle","Tiger",
"Rocket","Bullet","Knee","Foot","Hand"]
var randomNumber1 = parseInt(Math.random() * wordlist1.length);
var randomNumber2 = parseInt(Math.random() * wordlist2.length);
var name = wordlist1[randomNumber1] + " " + wordlist2[randomNumber2];
if(document.getElementById("result")){
document.getElementById("placeholder").removeChild(document.getElementById("result"));
}
var element = document.createElement("div");
element.setAttribute("id", "result");
element.appendChild(document.createTextNode(name));
document.getElementById("placeholder").appendChild(element);
}
</script>