title: Javascript issue managing variables
body: <p>Here is what I was attempting with my code:</p>
  
  <ol>
  <li>Click an element that has the selection() function.</li>
  <li>Function sets that element's width.</li>
  <li>Function selects previously click item (that also has selection() function)</li>
  <li>Function changes previous element's width</li>
  </ol>
  
  <p>Here is my JavaScript:</p>
  
  <pre><code>var lastOne;
  
  function selection(event) {
      event.target.style.width = "50px";
  
      lastOne.style.width = "10px";
      current = event.target.id;
      lastOne = document.getElementById(current);
  }
  </code></pre>
  
  <p>Here is the relevant HTML:</p>
  
  <pre><code>&lt;img src="images/Star.png" id="pic1" onclick="selection(event)"&gt;
  &lt;img src="images/Star.png" id="pic2" onclick="selection(event)"&gt;
  </code></pre>
  
  <p>Currently, it is editing the width of the element clicked, but does nothing to the previous element.</p>