Display image through JavaScript function
<p>I'm writing a javascript function that basically flips the coin and I'm trying to get it to return image but so far no luck.  I use img src tags to assign value to a variable but somehow I suspect that does not work and I wanted to check with you guys on how this is actually done?</p>

<p>Here  is my code:</p>

<pre><code>&lt;script type = text/javascript&gt;

        var headsCount = 0;
        var tailsCount = 0;     

        function start()
        {
            var buttonTwo = document.getElementById("coinButton");
            buttonTwo.addEventListener("click", coinResult, false);
        }

        function flip()
        {
            var faceValue = Math.floor((Math.random()*2)+1);                

            if (faceValue == 1)
            {
                headsCount++;
                return true; 
            }
            else
            {
                tailsCount++;
                return false; 
            }
        }

        function coinResult()
        {
            var result = document.getElementById("coinToss");
            var coinCount = document.getElementById("countNumber");

            &lt;img name = "Heads" src = "images/Heads.png" /&gt;

            if (flip() == true)
            {
                result.innerHTML = &lt;img src = "images/Heads.png" alt = "Heads" /&gt;
            }
            else
            {
                result.innerHTML = &lt;img src = "images/Tails.png" alt = "Tails" /&gt;
            }

            coinCount.innerHTML = "Heads Count: " + headsCount + " Tails Count: " + tailsCount;

        }

        window.addEventListener("load", start, false);

    &lt;/script&gt;
</code></pre>
