Pass name of global var to function that alters var?
<p>I encountered a strange problem today. </p>

<p>The good: I successfully changed a global var value from within a function(in other words the below example works fine when "passedVarName" is substituted with "a").</p>

<p>The bad: When trying to pass the global var name "a" (rather than putting it directly in the function) it fails to work.</p>

<p>Below is what I can't seem to get working:</p>

<p>(on click document should write "2" but instead writes "NaN" ?)</p>

<p>Javascript:</p>

<p></p>

<pre><code>  var a = 1;

  function click(passedVarName){

     passedVarName ++;

     document.write(passedVarName)

  };
</code></pre>

<p></p>

<p>HTML:</p>

<pre><code>&lt;a href="javascript:click('a')"&gt;Click this Button to alter global var "a".&lt;/a&gt;
</code></pre>
