Results 1 to 2 of 2

Thread: isNan w/ Array.

  1. #1
    Join Date
    Jan 2011
    Location
    England
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default isNan w/ Array.

    Hi there, I am currently messing around with a code that I made previously. It's a very simple code, and what I am looking to do is access the array elements (which do a calculation). I can access the elements fine and display the results, but I am looking to 'validate' the prompt box using 'isNan' but since I have changed my code, only the prompt box shows but no alert message.

    Here is my code:

    Code:
    <script type="text/javascript">
     
     var degFahren = prompt("Enter the degrees in Fahrenheit", 50); 
     var degCent;
     var myArray = new Array();
      
     myArray[0] = 0;
     myArray[1] = 1;
     myArray[2] = 2;
     myArray[3] = 3;
     myArray[4] = 4;
     myArray[5] = 5;
     myArray[6] = 6;
     myArray[7] = 7;
     myArray[8] = 9;
     myArray[9] = 32;
     
     degCent = myArray[5] / myArray[8] * (degFahren - myArray[9]);
     
     
     while (isNan(degFahren) == true)
     {
     alert("You did not enter a number");
     }
     while (isNan(degFahren) == false)
     {
     alert("\xB0" + degFahren + " Fahrenheit is \xB0" + degCent + " Centigrade.");
     }
     
     
     
     </script>
    If anyone could please give me any information I will be very thankful, it's been racking my brains all night!

    Thank you in advance.

  2. #2
    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

    There could be other problems but there is no isNan() method. It's isNaN()
    - 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
  •