Thanks for pointing out the issues with sum.  I think I have found a
decent solution, though I'm not certain of the performance hit.

Array.prototype.sum = function() {
        var x = 0;
        var a = this.length;
        while (--a -(-1)) {
                if (!isNaN(Number(this[a]))) {
                        x += this[a];
                } else {
                        return undefined;
                }
        }
        return x;
};

> Additionally, it would help to have a return statement :D.

Oops! Nice catch.  :)


> Lastly, there were a couple places where you did not use 'var' and the
> compiler caught it when I encapsulated your AS 1 into a class. I'll
post
> if you like.

Where?  I just double-checked. The only place I can think your compiler
might complain is Array.fill, but 'len' is an argument.

-Steven

_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to