title: Simple javascript game, hide / show random square
body: <p>I'm working on a simple game and I need some help to improve my code</p>
  
  <p>So here's the game: </p>
  
  <p>Some square show and hide randomely for a few seconds and you have to clic on them.
  I use RaphaelJS to draw the square and a few of JQuery ($.each() function)</p>
  
  <p>I work in a div, that's how I draw my squares (6 squares), x y are random numbers.</p>
  
  <pre><code> var rec1 = paper.rect(x, y, 50, 50).attr({
              fill: "blue",});
  </code></pre>
  
  <p><strong>Can I use for() to build my squares with a different var name for each one ?</strong> 
  I try with var = varName+i but it didn't work.</p>
  
  <p>To hide and show the square I use two functions call with two setTimeout:</p>
  
  <pre><code> function box1()  {rec1.show();}
   function hidebox1()  {rec1.hide();}
   var time1 = setTimeout(box1, 1000);
   var time1 = setTimeout(hidebox1, 2000);
  </code></pre>
  
  <p>I know it looks crappy... </p>
  
  <p><strong>I'm sure there is a way to use a toggle, or something more fancy to do that if you could help me finding it :) Because right now I have to do that for every square...</strong></p>
  
  <p>Thanks a lot for your help.</p>