How to invoke a function from another function in Javascript?
<p>I have a non-working code. I think it needs just a little mods and it should be working. I couldn't figure it out.  Just started studying JS. </p>

<pre><code>var add = function (a, b) {
    if (typeof a !== 'number' || typeof b !== 'number') {
        throw {
            name: 'TypeError',
            message: 'add needs numbers'
        }
    }
    return a + b;
}

var try_it = function (a, b) {
    try {
        add(a, b);
    } catch (e) {
        document.writeln(e.name + ': ' + e.message);
    }
}

document.writeln(try_it(2, 7));
</code></pre>

<p>It doesn't work. I get "undefined" error. However, if I invoke function add directly...</p>

<pre><code> var add = function (a, b) {
    if (typeof a !== 'number' || typeof b !== 'number') {
        throw {
            name: 'TypeError',
            message: 'add needs numbers'
        }
    }
    return a + b;
}

var try_it = function (a, b) {
    try {
        add(a, b);
    } catch (e) {
        document.writeln(e.name + ': ' + e.message);
    }
}

document.writeln(add(2, 7));
</code></pre>

<p>... I get the desired result. There must be something wrong with function try_it? </p>
