/**
* 得到数组平均值并依次排序及倒叙
* @param {string} a 字符串数值
* @param {string} b 字符串数值
* @return {string} 处理后的结果
*/
function addSum (a, b)
{
let result = '';
const len = Math.max(a.length, b.length);
a = a.padStart(len, '0');
b = b.padStart(len, "0");
let carry = 0;
for (let i = len - 1; i >= 0; i--)
{
const n = +a[i] + +b[i] + carry;
carry = Math.floor(n / 10);
result = (n % 10) + result;
}
if (carry)
{
result = '1' + result;
}
return result;
}
console.log(addSum('25456131398', '613213164'));
03-02
335
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
01-28
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交