title: JavaScript setInterval
body: <p>This is an example from a tutorial about setInterval, but it doesn`t explain it sufficiently for my newbie brain. I would appreciate if you could answer these questions</p>
  
  <p>i) does the 1000 millesecond timer mean that moveElement function will be triggered every second? In other words, after it has run, it will wait 1 second and then run it again?</p>
  
  <p>ii) is the purpose of moveElement to move the "redBox" 10 pixels to the left each time it runs? is that why "px" is used in the function</p>
  
  <p>iii) after moveElement runs for the first time,  does the new value for x (x+=10) replace the value of 0 in var x=0? i.e. does it get stored outside of the function in the variable x at the top of the program?</p>
  
  <pre><code>var x = 0;
  setInterval(moveElement,1000);
  
  function moveElement() {
    x+=10;
    var left = x + "px";
    document.getElementById("redbox").style.left=left;
  </code></pre>