SOURCE

var a = '142',b = '99'
function add(a,b){
    var len1 = a.length,len2 = b.length
    var maxLen = Math.max(len1,len2)
    var s1 = a.padStart(maxLen,0)
    var s2 = b.padStart(maxLen,0)
    var res = '',addOne = 0
    for(let i=maxLen-1;i>=0;i--){
        var temp = Number(s1[i])+Number(s2[i])+addOne
        addOne = temp>=10?1:0
        temp = temp>=10?temp%10:temp
        console.log(res,addOne,temp)
        res=temp+res
    }
    return addOne===1?1+res:res
}
console.log(add(a,b))
console 命令行工具 X clear

                    
>
console