Can someone explain the following JS Code
<p>This is simple word guessing game where the user gets infinite tries to guess the word (like Hangman). Please can someone explain to me how each section of code works with comments.</p>

<pre><code>var wordLetters     = ['G', 'O', 'A', 'T'];
var guessedLetters  = ['_', '_', '_', '_'];

function guessLetter(letter) {
    var goodGuess = false;
    var moreToGuess = false;
    for (var i = 0; i &lt; wordLetters.length; i++) {
        if (wordLetters[i] == letter) {
            guessedLetters[i] = letter;
            goodGuess = true;
        }
        if (guessedLetters[i] == '_') {
            moreToGuess = true;
        }
    }
    if (goodGuess) {
        alert('Yay, you found a letter!');
        document.write(guessedLetters.join(''));
        if (!moreToGuess) {
            alert('YOU WON!');
        } 
    } else {
        alert('Oh noes, thats not right!');
    }
}

guessLetter('G');
guessLetter('I');
guessLetter('O');
guessLetter('A');
guessLetter('T');
</code></pre>
