Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
Thread: help with school assignment
12-01-2009, 11:42 PM #1
- Join Date
- Dec 2009
- Thanked 0 Times in 0 Posts
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...
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
You can use the html framework on the next page for your program if you want.
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.
12-02-2009, 12:21 AM #2
Read especially rule 1.5
Now, *IF* you do the bulk of the work and get to the point where there is just one (or maybe two) thing(s) not working, *then* post the code here and likely somebody will help you.Be yourself. No one else is as qualified.
12-02-2009, 01:39 AM #3
- Join Date
- Mar 2006
- Thanked 132 Times in 123 Posts
I like the extra credit part the best.
12-02-2009, 02:29 AM #4
Ehhh... What's the point of doing a binary search in a list that's only 10 elements long??? Foolish waste of time.
And use a bubble sort??? Why, when you can use JS's builtin sort capabilities?
I know, I know. It's all a learning experience. Okay, fine. So why not make it "real world" in the process??Be yourself. No one else is as qualified.