Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-01-2009, 10:42 PM   PM User | #1
cory_rules
New to the CF scene

 
Join Date: Dec 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
cory_rules is an unknown quantity at this point
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.
cory_rules is offline   Reply With Quote
Old 12-01-2009, 11:21 PM   PM User | #2
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,237
Thanks: 59
Thanked 3,998 Times in 3,967 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Read this:
http://www.codingforums.com/rules.htm

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.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Old 12-02-2009, 12:39 AM   PM User | #3
mrhoo
Regular Coder

 
Join Date: Mar 2006
Posts: 708
Thanks: 30
Thanked 127 Times in 118 Posts
mrhoo will become famous soon enoughmrhoo will become famous soon enough
I like the extra credit part the best.
mrhoo is offline   Reply With Quote
Old 12-02-2009, 01:29 AM   PM User | #4
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,237
Thanks: 59
Thanked 3,998 Times in 3,967 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
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??
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Reply

Bookmarks

Tags
fail, java script, school

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:58 PM.


Advertisement
Log in to turn off these ads.