Always return a value from a snippet of javascript
<p>The problem:  taking an arbitrary string of javascript code and consistently returning a value from it and assigning it to a variable.  I need to build up a string of javascript that, when evaled, will consistently set a variable to whatever the return value of the original arbitrary string of javascript would return.  Example, this string of javascript:</p>

<pre><code>if(typeof(something) !== "undefined"){
  hello()
}
</code></pre>

<p>This is how I'm trying to do it now (and yes, I know the above snippet would not return anything)</p>

<pre><code>var result = (function(){
  if(typeof(something) !== "undefined"){
     hello()
   }
}.call(this)
</code></pre>

<p>And thus result is undefined.  How, in the above case and in all (or most) others, can I get a result that is not undefined?</p>
