If there are two letters the same, should both of them be shown when the letter is guessedmove on to the next one
or must the user guess that letter again to replace the second one?
There could be a loop for the code to find and replace all copies of the same letter. The indexOf method has arguments to tell it where to start its search. For "hardware" after finding the first "a" at 1, the search should start at 2 to find the second "a".
Also what about if the user keeps guessing the same letter that was in secretWord?
The code could look at the letter in displayWord at the location returned by indexOf to see if the letter was a dash.