Why is a named function not working when the unnamed was?
<p>I had this code:</p>

<pre><code>$('#testsPane').live("click", function() {//if the secondary ui nav tests is 

selected

//Displays the test list

var listOfTests = "";

   var subjects = [];
   var tests= [];
   var titles = [];

   var keysplit;
   var testSubj;

   var key, value;
   for (var i = 0; i &lt; localStorage.length; i++) {
       key = localStorage.key(i);
       value = localStorage.getItem(key);

       keysplit = key.split(".");


       tests.push(value);
       titles.push(keysplit[0]);
       subjects.push(keysplit[keysplit.length-1]);




}


for(var i=0; i &lt; tests.length; i++) {

    listOfTests += '&lt;div class="testDisplayBox"&gt;&lt;div 

class="subjColorBar"&gt;&lt;/div&gt;&lt;div class="testListIndiContain"&gt;&lt;span 

class="testListTitle"&gt;' + titles[titles.length-(i+1)] + '&lt;/span&gt;&lt;span&gt; in 

&lt;/span&gt;&lt;span class="testListSubj"&gt;' + subjects[subjects.length-(i+1)] + 

'&lt;/span&gt;&lt;/div&gt;&lt;div class="testListTags"&gt;&lt;span 

class="specTags"&gt;quiz&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;';

}

    var testsDashboard = '&lt;div id="testsList"&gt;' + listOfTests + '&lt;/div&gt;';

$('#selectedPane').append(testsDashboard);//adds the html to the pane to make it 

into the tests dashboard

})
</code></pre>

<p>The above code worked but I wanted to reuse some of it so I put it into a function. When I did that it did not work. Any idea why? The code below is with using a named function.</p>

<pre><code>function grabTestList() {//Displays the test list

   var keysplit;
   var testSubj;
   var key, value;
   for (var i = 0; i &lt; localStorage.length; i++) {
       key = localStorage.key(i);
       value = localStorage.getItem(key);

       keysplit = key.split(".");


       tests.push(value);
       titles.push(keysplit[0]);
       subjects.push(keysplit[keysplit.length-1]);

}}
$('#testsPane').live("click", function() {//if the secondary ui nav tests is selected

grabTestList();

   var listOfTests = "";
       var subjects = [];
       var tests= [];
       var titles = [];  

for(var i=0; i &lt; tests.length; i++) {

    listOfTests += '&lt;div class="testDisplayBox"&gt;&lt;div class="subjColorBar"&gt;&lt;/div&gt;&lt;div class="testListIndiContain"&gt;&lt;span class="testListTitle"&gt;' + titles[titles.length-

(i+1)] + '&lt;/span&gt;&lt;span&gt; in &lt;/span&gt;&lt;span class="testListSubj"&gt;' + subjects[subjects.length-(i+1)] + '&lt;/span&gt;&lt;/div&gt;&lt;div class="testListTags"&gt;&lt;span 

class="specTags"&gt;quiz&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;';

}

    var testsDashboard = '&lt;div id="testsList"&gt;' + listOfTests + '&lt;/div&gt;';

$('#selectedPane').append(testsDashboard);//adds the html to the pane to make it into the tests dashboard
}) 
</code></pre>
