Change Contents of the Bubble
Welcome to CS1315. Click on the python to add comments.

This page removed for FERPA compliance
View this PageEdit this Page (locked)Uploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

Final Exam Review Spring 2004: JavaScript

REMOVEDnk back to Sp2004 Final Exam Review

Questions and Answers?



(i=100; i>= 0; i–)
Correct?

Maybe show the whole thing? Mark Guzdial



The Simplest Possible Web REMOVED



A Simple Heading

This is a very simple web REMOVED




Well...that worked...I'm not sure how to show the actual stuff without it executing! if you want to see it, look at the "edit" REMOVED.....

<title> the simplest possible webpage </title>
<script>
function countToHundred()
{
   document.write("<ul>");
   for (i=100; i>= 0; i--)
   {
      document.write("<li> item number: ",i);
   }
   document.write("</ul>");
}
</script>
</head>
<body>
<h1>a simple heading</h1>
<p>this is a very simple web REMOVED</p>
<p><image src="mediasources/barbara.jpg" />
</p>
<script> countToHundred() </script>
</body>
</html>
Student1153


Or would it be the above but "for (i=1; i=100; i–)"? I have no idea...it was just a thought.

That would start the index at 1, decrementing each time, until the index was = 100, which would be immediately. Mark Guzdial

If you start your index at 1, and your condition for running your loop is that i=100, the loop will just never run and your code will continue to the next executable method. Generally, (like above), you set your condition for running a loop that your index is either greater than or less than some number, not purely equal.



Since we're just supposed to count down to 1, would it be: for (i=100; i> 0; i–)? Or does >= need to be included?



You can use "for (i=100; i>=1; i–)" or "for (i=100; i>0; i–)". They both say the same thing because the last time the "for loop" runs (when i=0), you do not want to include it. Both 0>0 and 0>=1 will return false, so the value i=0 will not print the last time and your loop will end.

Link to this Page