I saw a bunch of other posts on this topic but none in javascript. here is my code.
var theNumber = function digitAdd (base, exponent) { var number = 1;
i use it :)
var result = eval('123456'.replace(/(\d)(?=\d)/g, '$1+')); alert(result); // 21
without eval
var result = '123456'.split('').reduce(function(a,b){ return +a+ +b; }); alert(result); // 21