- Reset Game
- Book
- BASIC
-
Name
Original Resources
Download the original BASIC code. Check out the original page the text below was taken from in the Book.
Instructions From the Book
NAME is a silly little ice-breaker to get a relationship going between a computer and a shy human. The sorting algorithm used is highly inefficient - as any reader of Creative Computing will recognize, this is the worst possible sort for speed. But the program is good fun and that's what counts here.
NAME was originally written by Geoffrey Chase of the Abbey, Portsmouth, Rhode Island.
Modifications For This Version
Functionally, this is identical to the original. It's a simple, silly little program that reverses the user input, and then sorts the input alphabetically. There really isn't much more to do. I did use different font colors to help make the reading process easier, but that's it.
Technical Stuff
The main functionality is written in JavaScript. It's a little trickier than you might think at first. Sure, there are the standard things involved, like event listeners, and so forth. However, there's no built in function for reversing a string or sorting one.
In order to do this, I had to split the string into an array. Then run array functions on it, and then re-join the array back to a string. I also wrote my own simple reverse function.
Getting the user input to stay on the screen while the rest of the code runs was a little trickier than expected as well. Feel free to peek at the JS code and offer any suggestions for improvement.
I also styled the input forms to look like the user is entering text on the command line. That's a fun little experience. Someday, when browsers support caret-shape: block; I'll change the cursor. Until then . . .
Enjoy Name!
Name
Hello. My name is Creative Computer.
What's your name (first and last)?