By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,516 Members | 1,178 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,516 IT Pros & Developers. It's quick & easy.

Phone Number

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

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <title>Project2-3</title>
  4. </head>
  5. <body>
  6. <SCRIPT LANGUAGE="JavaScript">
  7. <!--HIDE FROM OLD BROWSERS
  8. var areaCode, exchange, number, phoneNumber;
  9. phoneNumber = areaCode +  "-";
  10. phoneNumber = phoneNumber + exchange + "-";
  11. phoneNumber = phoneNumber + number;
  12. document.write("<p>The phone number is " + phoneNumber + "</p>");
  13. //STOP HIDING FROM OLD BROWSERS -->
  14. </script>
  15. </body>
  16. </html>
Jun 17 '07 #1
Share this Question
Share on Google+
8 Replies


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

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <title>Project2-3</title>
  4. </head>
  5. <body>
  6. <SCRIPT LANGUAGE="JavaScript">
  7. <!--HIDE FROM OLD BROWSERS
  8. var areaCode, exchange, number, phoneNumber;
  9. phoneNumber = areaCode +  "-";
  10. phoneNumber = phoneNumber + exchange + "-";
  11. phoneNumber = phoneNumber + number;
  12. document.write("<p>The phone number is " + phoneNumber + "</p>");
  13. //STOP HIDING FROM OLD BROWSERS -->
  14. </script>
  15. </body>
  16. </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.
Jun 17 '07 #2

gits
Expert Mod 5K+
P: 5,390
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 ...
Jun 18 '07 #3

acoder
Expert Mod 15k+
P: 16,027
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.
Jun 18 '07 #4

P: 25
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
Jun 18 '07 #5

gits
Expert Mod 5K+
P: 5,390
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 ...
Jun 18 '07 #6

P: 25
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:
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html>
  4. <head>
  5. <TITLE>Project2-3</TITLE>
  6. </HEAD>
  7. <BODY>
  8. <PRE>
  9. <SCRIPT LANGUAGE="JavaScript">
  10. <!--HIDE FROM OLD BROWSERS
  11. var areaCode, exchange, number, phoneNumber;
  12. areaCode = 312;
  13. exchange = 876;
  14. number = 56789;
  15. phoneNumber= areaCode;
  16. phoneNumber += "-";
  17. phoneNumber +=exchange;
  18. phoneNumber +="-";
  19. phoneNumber += number;
  20. document.write(phoneNumber);
  21. //STOP HIDING FROM OLD BROWSERS -->
  22. </SCRIPT>
  23. </PRE>
  24. </BODY>
  25. </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
Jun 18 '07 #7

gits
Expert Mod 5K+
P: 5,390
... 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?
Jun 18 '07 #8

acoder
Expert Mod 15k+
P: 16,027
Just one point, language="Javascript" in your script tag is deprecated and out-of-date. Use type="text/javascript" instead.
Jun 19 '07 #9

Post your reply

Sign in to post your reply or Sign up for a free account.