HANGMAN
Code Explanation
thingelem.removeEventListener('click',
pickelement,false);
Removes the event handling
} Closes the j for loop iteration
} Closes if (lettersguessed....), that is, the
all-done test
} Closes the if (picked==secret[i]) true
clause
} Closes the for loop over letters in the secret
word iteration
if (not) { Checks if no letters were identified
steps[cur](); Proceeds with the next step of the hanging
iteration
cur++; Increments the counter
if (cur>=steps.length) { Checks to see if all steps are finished
for (i=0;i<secret.length;i++) { Starts a new iteration over the letters in the
secret word to reveal all the letters
id = "s"+String(i); Constructs the identifier
document.getElementById(id).textContent
= secret[i];
Obtains a reference to the element and sets it
to that letter in the secret word
} Close the iteration
ctx.fillStyle=gallowscolor; Set the color
out = "You lost!"; Sets the message
ctx.fillText(out,200,80); Displays the message
ctx.fillText("Re-load the
page to try again.",200,120);
Displays the reload message