so my script should run on page load √ then generate a word √ then hide the word with a string of dashes equal to its length √ but then it picks another word to replace the first one?
Ive tried to move the hiddenword generator around in my document but without it being in the start function it wont make the string i need.
function start() {
usedletters = [];
word = words[Math.floor(Math.random() * words.length)];
life = 9;
console.log(word)
for (var i = 0; i < word.length; i++) {
hiddenword[i] = ("-");
console.log(word)
console.log(hiddenword)
}
// all of this gets the id from main document then pushes what javascript generates
document.getElementById("win").innerHTML = (wincount);
document.getElementById("hidden").innerHTML = (hiddenword);
document.getElementById("used").innerHTML = ("");
document.getElementById("life").innerHTML = ("9");
document.getElementById("victory").hidden
}
start();
I really just need it to pick the first word and not select a new one.
Aucun commentaire:
Enregistrer un commentaire