title: No need to define a variable twice
body: <p>If a variable <strong><em>could</em></strong> be defined in a function, even if no value is assigned, it becomes a local variable</p>
  
  <p>so, is <strong>testB()</strong> better programming?</p>
  
  <pre><code>var test = 'SNAP!'
  function testA(boolean) {
      if (boolean) var test = 'OK';
      else var test = null;
      alert(test);
  }
  function testB(boolean) {
      if (boolean) var test = 'OK';
      alert(test);
  }
  testA(true); // 'OK'
  testB(true); // 'OK'
  testA(false); // null
  testB(false); // undefined, no error
  </code></pre>
  
  <p><em>In my specific case test's global value ('SNAP!') is neither expected nor required.</em></p>