Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning JavaScript 5th Edition
This is the forum to discuss the Wrox book Beginning JavaScript, 5th Edition by Jeremy McPeak; 978-1-118-90333-9
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning JavaScript 5th Edition section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old December 28th, 2016, 10:42 AM
Registered User
Points: 5, Level: 1
Points: 5, Level: 1 Points: 5, Level: 1 Points: 5, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2016
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Try it out

I cannot get any of the examples to generate on Chrome. I am using Notepad++ and saving files using .html. The code download files load and display correctly . Not sure what I am doing wrong.
<!DOCTYPE html>
<html lang="en">
<head><title>Chap4 Example1</title>
</head>
<body>
<script>
function converToCentigrade(degFahren){
var degCent =5/9 * (degFahren - 32);

return degCent;
}
var degFahren = [212, 32 , -459.15];
var degCent = [];
var loopCounter;

for (loopCounter = 0; loopCounter <= 2; loopCounter++ ){
degCent[loopCounter] = convertToCentigrade(degFahren[loopCounter]);
}

for (loopCounter =2; loopCounter >= 0; loopCounter--) {
document.write("Value " + loopCounter + " was " + degFahren[loopCounter] + "degrees Fahrenheit");

document.write( "whic is " + degCent[loopCounter] + "degrees centigrade <br />");


}

</script>
</body>



</html>

Last edited by modusrose; December 28th, 2016 at 11:45 AM.
Reply With Quote
  #2 (permalink)  
Old January 31st, 2017, 04:06 PM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2017
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Your code is wrong

In the code that you provided, your function is spelled incorrectly. You have converToCentigrade. It should be convertToCentigrade. Change that and your code will work.

I would suggest learning how to use Chrome's developer tools. It'll help you to figure out why your code isn't working. To get there quickly, while you are on the Chrome page that is loading your code, right-click and choose Inspect. Then select "Console" on the page that opens up. If you've made an error, you'll see it listed.

Hope this helps!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off



All times are GMT -4. The time now is 02:52 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.