I'm trying to get the underscores for my hangman game to show up on the HTML page, but it doesn't seem to be working. When I do run the HTML page, all I see is the text box. Any ideas on why this is happening?
CODE:
//create array for words
var listWords = ['cat', 'dog', 'mouse'];
//displays the word in underscores
var hiddenWord = [];
//choose word randomly
//Math.random returns integer between 0 (inclusive) and 1 (exclusive)
//multiply Math.random with the length of the listWords array
//Math.floor rounds down to nearest integer
//note that array indexes start counting from 0, hence why we need to make sure the listWords index never reaches the actual length of the array
var chosenWord = listWords[Math.floor(Math.random() * listWords.length)];
//number of tries the user gets before game over
var lives = 5;
var s;
function setup() {
for (i = 0; i < chosenWord.length; i++) {
hiddenWord[i] = '_';
}
s = hiddenWord.join(' ');
return s;
}
function main() {
var underscores = document.getElementById('hiddenWord');
underscores.innerHTML = setup();
}
<!--adding a title that will appear on the webpage-->
<h1>Hangman</h1>
<!--create a text box-->
<input id='letter' type='text' maxlength="1" minlength="1" placeholder="Guess a letter" />
<div id='hiddenWord'></div>
<!--add instructions for the player-->
<h2>Instructions</h2>