Function returns "undefined" while alert() gives proper value
<p>I want to ask you what can cause this problem: I want to get a value calculated in function, and when I get it as returned value it returns "undefined", but if I replace <code>return value</code> by <code>alert(value)</code>, it works.</p>

<p>Code for better explanation what I mean:</p>

<p>That one does not work - returns "undefined"</p>

<pre><code>function aaa() {
    // calculating...
    return value;
}

alert(aaa());
</code></pre>

<p>And that one works - returns expected value:</p>

<pre><code>function aaa() {
    // calculating...
    alert(value);
}
</code></pre>

<p>I'm new in JavaScript and don't have any idea what can cause it.
Thanks for your help!</p>

<hr>

<p>update - actual code: (it's still in progress so don't try to understand what it is supposed to do)</p>

<pre><code>function sprawdz(){

    this._odswiezDane = function(){


        this.struktura  = _struktura($('#linie'));
        alert(this.struktura);

    };

    function _struktura(a){

        temp = a.children('table').children('tbody').children('tr').children('td');

        if (temp.html() != null) {
            temp.each(function(){

                return [[_struktura($(this))],3];
              //        alert ([[_struktura($(this))],3]);  

            });
        } else
            return [0, 3];

    };

}
</code></pre>

<p>and the #linie object is a div where I dynamically add tables in tables... some kind of structure.</p>

<p>Previously I thought it's too complicated to paste it here and that it would be simpler to cut the code, in fact I wanted to save your time - sorry for doing it!</p>

<hr>

<p>next update: I'm sure every variable is declared.</p>
