# Hangman

/* This is a sample application provided with LiveWire. Read the LiveWire Developer's Guide for a tutorial description. Copyright 1996 Netscape Communications Corp. */ // Initialize gameno if have not played before // client.newgame is set to "True" for first game and by youwon/youlost if (client.gameno == null) { client.gameno = 1 client.newgame = "true" } // Initialize secret word, answer, and letters used for each new game. if (client.newgame == "true") { if (client.gameno % 3 == 1) client.word = "LIVEWIRE" if (client.gameno % 3 == 2) client.word = "NETSCAPE" if (client.gameno % 3 == 0) client.word = "JAVASCRIPT" client.answer = InitAnswer(client.word) client.used = "" client.num_misses = 0 } client.newgame = "false"; // set flag so don't initialize next time // Process guess if specified if (request.guess != null) { request.guess = request.guess.toUpperCase().substring(0,1) client.used = client.used + request.guess + " " request.old_answer = client.answer client.answer = Substitute(request.guess, client.word, client.answer) if (request.old_answer == client.answer) client.num_misses = parseInt(client.num_misses) + 1 } if (client.answer == client.word) redirect(addClient("youwon.html")) // redirect if you win. else if (client.num_misses > 6) redirect(addClient("youlost.html")) // redirect if you lose.

    write(client.answer)

You have used the following letters so far: write(client.used)

What is your guess?

To learn how to play Hangman, please read the rules.