1. Home
  2. Computing & Technology
  3. JavaScript

Hangman Script Tutorial

page three

clr gif

 

<< Previous Page

var al = '--------------------------';
if (qsParm['al']) al = qsParm['al'];

This string field is initialised to 26 dashes. As guesses are made the appropriate letters of the alphabet will be substituted. This serves both to keep track of which letters have already been guessed as well as to simplify the display of the answer field.

var wr = 'xhwdarqpnez';
var dc = '7!3@4#1$^5*~:6 +8=`<2-0>_/?9';
var wx = 0;
if (qsParm['w']) wx = wr.indexOf(qsParm['w']);

The wr field serves to encrypt the counter that keeps track of how many wrong guesses have been made so far while the dc field serves as an encryption table for the answer array. The indexOf method is used on the wr string to locate the position of the retrieved w parameter. That position indicates the number of wrong guesses made so far.

Explore JavaScript
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. JavaScript

©2009 About.com, a part of The New York Times Company.

All rights reserved.