|
 |
My daughter likes games and riddles and I like math. So, I took an old math riddle and will let Javascript
do the math for you. |
Follow the steps below on paper first (with a calculator). Then try it with the form.
|
|
|
|
After the calculation is complete, think of an American State that begins
with your letter.
Now think of a State that begins with the next
letter of the alphabet
. |
OK, do you think I can guess what states you are thinking of? Click the "Tell Me" button below when you are
ready. |

|
|
Notes: This form accepts the users name in the prompt and writes it near the bottom of the game.
The random number function uses the math.random() function, multiplies by 9 to get a number between .09
and .89, adds .5 to get a number that will round up (or down) to a number between 1 and 9
When the user submits the number, the form validates that they submitted a number, that the number was
between 1 and 9 and that the number does not contain a decimal point.
The math fills in the rest of the form. It is mostly basic arithmetic, except for the parsing of the number
to add the sum of the digits in step 8, which then checks to make sure the answer is a single digit - with
the numbers 2 and 7, the return at that point is 25. |
|
Of course, the final number is always 7, which translates to G which has to be Georgia (the only state
that starts with G) and H is Hawaii, again, the only state that starts with H. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|