Help - Search - Members - Calendar
Full Version: Simple JavaScript question.
Invision Power Services > Community Forums > Community Web Design and Coding
IAIHMB
I'm reading a JavaScript book, and at the end of every chapter i'm assigned a quiz to complete before moving on to the next chapter. In this chapter's quiz, i'm suppose to ask the user for a degree value in centrigrade, convert it to farenheit, and write it to the page. This is the code that i've got, and to the best of my knowledge it should work, but it doesn't:

CODE
<html>
    <head>
        <title>Javascript Quiz 1</title>
    </head>
    <body>
        <script language="Javascript" type="text/javascript">
            
            // Ask the user which temperature, in centigrade, that he slash she would like to convert to fahrenheit.
            var degCentigrade = prompt("Enter the degrees in centigrade.",50);
            
            // Define the fahrenheit variable, and do the math.
            var degFahrenheit = 9 / 5 * degCentegrade + 32;
            
            // Display the user what value he slash she entered for degCentigrade and give him slash her the answer.
            document.write(degCentigrade + "xNN centigrade is " + degFahrenheit + "xNN fahrenheit.");
            
        </script>
    </body>
</html>


There is an detailed answer guide in the back of the book, but the only difference I see between his code and my code is the name of the variables used. Thanks a lot for any information, chances are this is just some stupid mistake. sad.gif
Brendon Koz
...ya know, the funny thing is, I have no idea. Oh, and you're right, this is simple JavaScript. tongue.gif Firefox wouldn't even let me change the variable in the prompt box since you predefined it, although IE would. These are the types of reasons why I try to stay away from Javascript...

Oh. Check your spelling of Centigrade in your equation.
IAIHMB
Oi, I missed that, I bet that does it. Thanks a lot! wub.gif
FormulaC
yea spelling of centigrade in equation
IAIHMB
The thing is, I cannot believe that I missed that. I could have swarn that I, er, at least double checked all of my variables before posting. It did it, and it works for me in Firefox. Once again, thanks, now I can move on to the 1,000+ pages. tongue.gif
Brendon Koz
It's been proven that the mind will bend certain things when you re-read something that's fresh in your mind. Your mind will *think* for you and actually misinterpret the words you read because you *think* they are correct. That is why English professors and/or tutors will ask/tell you to have someone else read over your writings to help proof read.

I would easily assume the same can be said of programming, as it is technically a language all of its own.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.