Site hosted by Angelfire.com: Build your free website today!
Guess the # Game

Math Notes

When you want to do math on a number you get out of a text box you will want to multiply it by 1 first. Otherwise you will end up concatenating them.

if you wanted to add 4 and 5 you expect 9 but if you dont tell javascript that 4 and 5 are numbers than it will think they are text.

ie:

alert('a' + 'b') would alert "ab" together. (Try it)

now try to alert this:

alert('4' + '5') (Try it>)

now try alert('4'*1 + '5'*1) (Try it)

Other Things to look at

The Form Tag. Using forms in HTML with Javascript can be very powerful. In addition we have added the Submit button which is a special button that does whatever the form action is when clicked.

Also we are using the JavaScript switch Statement.

Guess a number 1-20
Your Guess: