|
help with school assignment
hey all, i've been failing in my attempt to grasp JS. this is my last assignment..any help would be greatly appreciated...
Exercise:
Write a program that will ask the user to enter ten items (names of people, numbers,
addresses, or whatever). Use a prompt box to get the user’s input. You’ll need to put it
in a loop of some sort.
After you’ve gotten all ten items, sort them. You can use whatever sorting method you
prefer (I’d suggest the bubble sort). Display the items in order, using either alert boxes or
document.write statements.
You can use the html framework on the next page for your program if you want.
Extra credit:
After displaying the items, ask the user to enter an item to search for. Use the binary
search (NOT the serial search!) to find the item in the list and display the item’s location
in the list. For example if the item was the first in the list, say that it was item # 1, the
second item is item # 2, etcetera. Remember, we want to tell the user which place the
item is in, not which element it is! Don’t tell the user that it is item # 0 if it is the first
one in the list. The user won’t understand that we’re indexing from zero.
|