Darn, I wasn't fast enough to get this into rev 3 :) Array.prototype.sum = function() { var x = 0; var a = this.length; while (--a -(-1)) { var n = Number(this[a]); if (!isNaN(n)) { x += n; } else { return undefined; } } return x; };
While you were casting to Number for the test, when you actually added you were adding the initial value. This meant strings were concatenated instead of added.
Peace C _______________________________________________ Flashcoders@chattyfig.figleaf.com 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