function getSumNumber(num) { var sum = 0, tmp; while (num) { tmp = num % 10; num = (num - tmp) / 10; sum += tmp; } return sum; } alert(getSumNumber(2610));