Phone Number

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Brigitte Behrmann
    New Member
    • Jun 2007
    • 25

    #1

    Phone Number

    The question goes like this:
    The following code contains errors, find and correct the errors.

    Code:
    <html>
    <head>
    <title>Project2-3</title>
    </head>
    <body>
    <SCRIPT LANGUAGE="JavaScript">
    <!--HIDE FROM OLD BROWSERS
    var areaCode, exchange, number, phoneNumber;
    phoneNumber = areaCode +  "-";
    phoneNumber = phoneNumber + exchange + "-";
    phoneNumber = phoneNumber + number;
    document.write("<p>The phone number is " + phoneNumber + "</p>");
    //STOP HIDING FROM OLD BROWSERS -->
    </script>
    </body>
    </html>
  • Logician
    New Member
    • Feb 2007
    • 210

    #2
    Originally posted by Brigitte Behrmann
    The question goes like this:
    The following code contains errors, find and correct the errors.

    Code:
    <html>
    <head>
    <title>Project2-3</title>
    </head>
    <body>
    <SCRIPT LANGUAGE="JavaScript">
    <!--HIDE FROM OLD BROWSERS
    var areaCode, exchange, number, phoneNumber;
    phoneNumber = areaCode +  "-";
    phoneNumber = phoneNumber + exchange + "-";
    phoneNumber = phoneNumber + number;
    document.write("<p>The phone number is " + phoneNumber + "</p>");
    //STOP HIDING FROM OLD BROWSERS -->
    </script>
    </body>
    </html>
    Yes - and? Are you expecting to be spoon fed forever? The answers to the above (obvious as they are) can be found in the same way that I and others have been trying to drum into you, and which your excuse for a teacher should have done in the first lesson. Use the console - that's why it's there.

    Comment

    • gits
      Recognized Expert Moderator Expert
      • May 2007
      • 5390

      #3
      hi ...

      lets try it together again ... ok? what do you see at the moment, when executing the script? and what do you expect to see? tell me ... then we may find the solution in the next step ;)

      kind regrads ...

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Originally posted by Brigitte Behrmann
        The question goes like this:
        The following code contains errors, find and correct the errors.
        As Logician points out, the error console will find these for you. Use a browser like Firefox to see some proper error messages.

        Comment

        • Brigitte Behrmann
          New Member
          • Jun 2007
          • 25

          #5
          Originally posted by acoder
          As Logician points out, the error console will find these for you. Use a browser like Firefox to see some proper error messages.
          Hi All

          Thanks for your comments. I realise I have forgotten to post the code that I had made changes on......(sorry Logician, I did not expect to be spoon fed as you put it!) I will do this as soon as I get home from work as it is all on my personal laptop.... strict rules at work... no private work may be done.

          One question about this error console... I had a look for the first time last night, can you only enter one line of code at a time, I cannot see how to enter all the code and then validate...???

          Chat again when I get back home.
          Thanks
          BB

          Comment

          • gits
            Recognized Expert Moderator Expert
            • May 2007
            • 5390

            #6
            hi ...

            during execution of your script in the browser the errors occur in the console ... warnings too ... load your page and you will see ...

            kind regards ...

            Comment

            • Brigitte Behrmann
              New Member
              • Jun 2007
              • 25

              #7
              Originally posted by gits
              hi ...

              during execution of your script in the browser the errors occur in the console ... warnings too ... load your page and you will see ...

              kind regards ...
              Hi Gits
              Back from the office - whew what a long & tiring day and now this to contend with....
              My Changes:
              Code:
              <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
              "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
              <html>
              <head>
              <TITLE>Project2-3</TITLE>
              </HEAD>
              <BODY>
              <PRE>
              <SCRIPT LANGUAGE="JavaScript">
              <!--HIDE FROM OLD BROWSERS
              var areaCode, exchange, number, phoneNumber;
              areaCode = 312;
              exchange = 876;
              number = 56789;
              phoneNumber= areaCode;
              phoneNumber += "-";
              phoneNumber +=exchange;
              phoneNumber +="-";
              phoneNumber += number;
              document.write(phoneNumber);
              //STOP HIDING FROM OLD BROWSERS -->
              </SCRIPT>
              </PRE>
              </BODY>
              </HTML>
              I take it the purpose of this was to add code for a program that assigns the area code, exchange and number variables to the phoneNumber variable, separated by dashes. The phone number I presume should be displayed using a doc write statement.
              The only way I could get this to work was by assigning an area code, exchange and number value.
              How would one do this otherwise?
              Seems to work but just want clarification I have done it correctly.

              Thanks
              BB

              Comment

              • gits
                Recognized Expert Moderator Expert
                • May 2007
                • 5390

                #8
                ... hmmm ... congrats ... ;) i thought the same ... can't see any other error with that ... it should be the solution ... does anybody has an other interpretation of that task?

                Comment

                • acoder
                  Recognized Expert MVP
                  • Nov 2006
                  • 16032

                  #9
                  Just one point, language="Javas cript" in your script tag is deprecated and out-of-date. Use type="text/javascript" instead.

                  Comment

                  Working...