Results 1 to 3 of 3

Thread: Need Help with a javascript program to find the max of 10 values

  1. #1
    Join Date
    Dec 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Need Help with a javascript program to find the max of 10 values

    My assignment was to write a javascript program to find the max of 10 values. I have attached the code file of my work and i need someone to check it to see why its not working the way i need it too!! Thanks!!

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    We do not do homework. Ask a specific question.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Well, we will help with homework if you've obviously made an effort, which your code shows that you have. The main problem is that here:

    Code:
    input1 = window.prompt("Enter your 10 numbers" , "0" );
    input1 is a string and before you compare it to max1 which (at least originally) is a number, nothing is done to convert it to a number. So here:

    Code:
     if(input1 > max1)
    comparison is performed on the basis of alphabetizing.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •