Thread: Try it out
View Single Post
  #1 (permalink)  
Old December 28th, 2016, 11:42 AM
modusrose modusrose is offline
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.
Reply With Quote