//递归求数字各个位数上的数字的和
function getEachNumSum(x){
if(x < 10){
return x;
}
return (x%10) + getEachNumSum(parseInt(x/10));
}
console.log(getEachNumSum(126));
网友评论