Second part of code works earlier then the first part
<p>I have a tag list which saved in an object. I want it to give an error message when tag list is empty.  Altough the checking part of code is beeing end of the code, it works before.</p>

<pre><code> $("#Save").click(function(e){
    var size = 0;
    tagArray = new Array;
    for (key in tagObjectList )
    {
        tagArray.push(tagObjectList[key].toString());
        console.log(key);
        ++size;
        alert(size); //it's displayed after below alert. diplays  1,2,...,tag count
    }

    alert(size); // displays 0. ???
    if (size == 0) {
        alert("There is no tag!");
        return false;
}
    $("#tagData").val('[' + tagArray.toString() + ']');
}); 
</code></pre>

<p>What is wrong here? Could you help me please?</p>
