title: How do you use javascript to get a random result from an array over a time interval?
body: <p>I want the function <em>tim</em> below to get an ever changing route from Array every 500 milliseconds.  Instead, in my JS console I receive the following repeating error:</p>
  
  <p>VM5550:1 Uncaught SyntaxError: Unexpected end of input</p>
  
  <p>What is going on here and what do I need to do to get the result I'm looking for?</p>
  
  <p>My code:</p>
  
  <pre><code>var Array = ["http://files.parsetfss.com/9.png", 
  "http://files.parsetfss.com/5.png",
  "http://files.parsetfss.com/6.png",
  "http://files.parsetfss.com/7.png",
  "http://files.parsetfss.com/8.png"];
  
  var sampl = _.first(_.sample(Array, 1));
  var tim = setInterval(sampl, 500);
  </code></pre>
  
  <p>I also tried wrapping <em>sample</em> in a function like so:</p>
  
  <pre><code>var sampl = function(){return _.first(_.sample(Array, 1))};
  </code></pre>
  
  <p>I'm still not getting the desired result but now I'm getting a result that is consistently even 7 or 11 (after refeshing the screen a number of times.</p>