Count Down Clock doesn't return when time ran out.
<p>I'm using code from this answer:  <a href="http://stackoverflow.com/a/6501353/494901">http://stackoverflow.com/a/6501353/494901</a></p>

<p>Basically when the timer ends, I want it to return true to my functions such that when it's over I can do stuff only after it's over. But the script is never returning, it ends, but it never returns back to the method it's called. </p>

<pre><code>function countdown( elementName, minutes, seconds )
{
    var element, endTime, hours, mins, msLeft, time;

    function twoDigits( n )
    {
        return (n &lt;= 9 ? "0" + n : n);
    }

    function updateTimer()
    {
        msLeft = endTime - (+new Date);
        if ( msLeft &lt; 1000 ) {
            return true; 
        } else {
            time = new Date( msLeft );
            hours = time.getUTCHours();
            mins = time.getUTCMinutes();
            element.innerHTML = (hours ? hours + ':' + twoDigits( mins ) : mins) +
                ':' + twoDigits( time.getUTCSeconds() );
            setTimeout( updateTimer, time.getUTCMilliseconds() + 500 );
        }
    }

    element = document.getElementById( elementName );
    endTime = (+new Date) + 1000 * (60*minutes + seconds) + 500;
    return updateTimer();
}
</code></pre>
