Javascript slider loop
<p>I have been trying to create an image slider for html by changing the value of the image element, using a loop to go through each image and then returning to the original image.</p>

<p>However once it reaches the end of the loop it doesn't continue.</p>

<p>Here is my Js code:</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>window.onload = function() {
  var x = 0
  while(x&lt;1000){
    setTimeout(function() {
      document.getElementById('carousel').src='img/header2.jpg';
      setTimeout(function() {
        document.getElementById('carousel').src='img/header3.jpg';
        setTimeout(function() {
          document.getElementById('carousel').src='img/header.jpg';
          }, 5000);
        }, 5000);
      }, 5000);
    x = x+1
  }
}</code></pre>
</div>
</div>
</p>