Wrox Programmer Forums
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old December 28th, 2016, 11: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 12:45 PM..
  #2 (permalink)  
Old January 31st, 2017, 05: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!






Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.