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:
If anyone could please give me any information I will be very thankful, it's been racking my brains all night!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>
Thank you in advance.![]()



Reply With Quote

Bookmarks