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..
|