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 this :
'123456'.split('').map(function(e){return parseInt(e)}).reduce(function(a,b){return a+b}); //21
[...'123456'].map(e=>parseInt(e)).reduce((a,b)=>a+b); //21