Another assignment I’m not understanding. I’ll post the original code which I re-typed and everything ran fine. Now I need to make the following changes to the code:
[COLOR=”#0000CD”]Task 2: Make modifications in the sample code (see below)
Make modifications to the textbook example (Converting a Series of Fahrenheit Values) and instead of hard coding the condition state value of the loop (line 9) and initial state value of the loop (line 13), use the length property.
[CODE]<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<body>
<script type=”text/javascript”>
var degFahren = new Array(212, 32, -459.15);
var degCent = new Array();
var loopCounter; [COLOR=”#FF0000″]//Line 9[/COLOR]
for (loopCounter = 0; loopCounter <= 2; loopCounter++)
{
degCent[loopCounter] = 5/9 * (degFahren[loopCounter] – 32); [COLOR=”#FF0000″]//Line 13[/COLOR]
}
for (loopCounter = 2; loopCounter >= 0; loopCounter–)
{
document.write(“Value ” + loopCounter + ” was ” + degFahren[loopCounter] +
” degrees Fahrenheit”);
document.write(” which is ” + degCent[loopCounter] +
” degrees centigrade<BR>”);
}
</script>
</body>
</html>
Based on the instructions I take Line 9 and would change it from var loopCounter; to var len= temp.length; which is the initial array of temps 0, 1, 2? (I’m also looking at examples on W3Schools.)
For Line 13 degCent[loopCounter] = 5/9 * (degFahren[loopCounter] – 32); I would change loopCounter to temp.length;?
Will I not also have to change every other place loopCounter is used which he doesn’t state in the instructions?
Thank you!