title: How to stop animation
body: <p>I am rather new to programming and have just begun learning Javascript. I creating a personal portfolio in which I want an image of myself to slide horizontally from one end of the screen the other end. I have the code that gets it to slide right horizontally, but I do no know how to stop it.</p>
  
  <p>My code looks like this at the moment:</p>
  
  <pre><code>var move = null;
  
  function doMove() {
      move.style.left = parseInt(move.style.left) + 2 + 'px';
      setTimeout(doMove);
  }
  function init() {
      move = document.getElementById("myimge");
      move.style.left = "0px";
      doMove();
  }
  window.onload = init;
  </code></pre>
  
  <p>I think I am supposed to write an if statement and call on the clearTimeout function to stop the animation, but I cant figure out the code. Any assistance would be great. </p>