p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Beginning JavaScript 5th Edition (http://p2p.wrox.com/forumdisplay.php?f=793)
-   -   Try it out (http://p2p.wrox.com/showthread.php?t=99319)

modusrose December 28th, 2016 11:42 AM

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>
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 />");




Rebecca January 31st, 2017 05:06 PM

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!

All times are GMT -4. The time now is 05:19 PM.

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