variables in javascript
<p>I have two arrays sd[16][16] and gd[16][16] in javascript. I need to compare the values of the arrays.</p>

<pre><code>var score=0;
document.write("&lt;table&gt;");
for(c1=0; c1&lt;16; c1++)
{   document.write("&lt;tr&gt;");
    for(c2=0; c2&lt;16; c2++)
        document.write("&lt;td onClick='changeColor(this);'&gt;" + gd[c1][c2] + "&lt;/td&gt;");
    document.write("&lt;/tr&gt;");
}
document.write("&lt;/table&gt;");

function changeColor(tdd)
{
    if(tdd.bgColor=='white')
    {
        tdd.bgColor='red'; 
        if (gd[c1][c2] == sd[c1][c2])
            score+=5; 
        else
            score-=2; 
    }
    else
    {
        tdd.bgColor='white'; 
    }
}
</code></pre>

<p>However, when I try to display the score later, the score is not displayed.</p>

<pre><code>function scc()
{
    document.getElementById('scf').innerHTML = score;
}
&lt;/script&gt;
&lt;br&gt;&lt;br&gt;&lt;center&gt;&lt;button type='button' onclick='scc()'&gt; Click to see current score&lt;/button&gt; &lt;p id="scf"&gt;0&lt;/p&gt; &lt;/center&gt;
&lt;br&gt;&lt;br&gt; &lt;center&gt;&lt;input type="submit" value="Get Solution"/&gt;&lt;/center&gt;
</code></pre>

<p>Could someone please tell me what I am doing wrong?</p>
