Running Javascript functions in order (one after the other)
<p>when I try the following:</p>

<pre><code>if(myFunction() == "3") {
    alert('its three!');
}
</code></pre>

<p>my function returns undefined, when I know that it is actually returning 3.
Is this because javascript evaluates the if statement before the function can return a value?</p>

<p>if so how can I do something like this:</p>

<pre><code>var result = myFunction();

// Wait until result is there

if(result == "3") {
    alert("its three!");
}
</code></pre>
