View Single Post
Old June 16th, 2008, 02:07 PM
Old Pedant Old Pedant is offline
Friend of Wrox
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts

I'm sorry, but your core logic is just too messed up to bother trying to fix this code.

Just for starters, you test the WRONG THING for a "win"!!!

                if (ranword.charAt(num) == guessletter) 
                    foundLets += ranword.charAt(num);
                    if ((document.hangman.word.value).indexOf('*') == -1) 
See? You add the found letter to the list of letters in "foundLets", but *THEN* you check the visible word to see if there are no more asterisks.

But you NEVER UPDATE the visible word with what's in foundLets!!!

Really, it would take me much more time to fix your code than it did for me to write the code all over, which I already did once for you.