March 31, 2010

Tutorial: Guess My Number

Continuing the Javascript tutorial series. The guess-my-number.html program is truly a straightforward example of 1978 programming style, with an interactive prompt that blocks the program flow to have the user guess a secret number. (view source)

Not very modern, but a classic first program. Javascript certainly permits this style.

Any other ideas? What other "good first programs" are there?

I feel like I'm looking for some intersection between "what is understandable" to a sixth grader and "what is cool" to the same set.

Posted by David at March 31, 2010 09:58 PM

How about string manipulation? Encrypting strings using a cipher. Other simple encryptions.

Posted by: Shakeel Mahate at April 1, 2010 09:50 AM

How about playing the other side of the same game (the guesser?) log2(100) is 6.6, so give it 6 guesses so it will sometimes win. It will even have some actual computer science concepts hiding in it, but you don't have to tell.

For a next step, do you remember the game "mastermind"? I thought that was excellent for pogramming projects - just the right level of difficulty to be accessible without being trivial. In JS, there should be some opportunity to polish up the UI as well. Once again, one can program both sides of it.

Posted by: Terran at April 1, 2010 09:30 PM

Ok, I did this:

It's ~80 lines.

Posted by: Terran at April 8, 2010 10:45 PM

Your post brings back memories - when I was a college student my husband (boyfriend then) and I taught Basic classes to kids - and Guess-the-number was the first proper program we made them write too!

I think the next exercise we had them do was a report card that allowed input of a few subjects and then calculated the average.

Posted by: Meryl van der Merwe at May 2, 2010 12:17 AM
Post a comment

Remember personal info?