When you write out the word loop through the letters in chair and check if the letter has been clicked. If so then add the letter to the "final" text. Example:
var clickedLetters = 'hra';
var correctWord = 'chair';
var finalWord = '';
for (var i = 0, len = correctWord.length; i < len; i++) {
var letter = correctWord[i];
if (clickedLetters.search(letter) != -1)
finalWord += letter;
else
​ finalWord += '_';
}
alert(finalWord);