title: JavaScript while loop error: Unexpected token
body: <p>So I have made a code for some coursework, the code is suppose to start a function on page load which will then run the function of changing the traffic light image on screen. It is suppose to keep on changing forever however the program crashes or fails to load when I try to run. Before you suggest the problem is that the variable used in the condition isnt changed, I have tried to change it in the following code. when I ran it in the chrome debugger this is the thing that came up; 'Uncaught SyntaxError: Unexpected token &lt;'.</p>
  
  <pre><code>&lt;DOCTYPE html&gt;
  &lt;html&gt;
      &lt;body onload="infinity()"&gt;
          &lt;p&gt;&lt;/p&gt;
          &lt;h1&gt;Traffic Light Sequence&lt;/h1&gt;
          &lt;img id ="trafficlight" src="r.jpg"&gt;
          &lt;script&gt;
              var images  = [
                  "r.jpg",
                  "randy.jpg",
                  "g.jpg",
                  "y.jpg"
              ];
              var counter = 0;
              function start() {
                  counter = counter + 1;
                  if(counter == images.length) counter=0;
                  var image = document.getElementById("trafficlight");
                  image.src=images[counter];
              }
              var a = 100;
              function infinity() {
                  while (200&gt;a) {
                      setTimeout(start(), 3000);
                  }
                  a = a - 25;
              }
          &lt;/script&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>