1def sum_of_digits(n):
2 sum = 0
3 while (n != 0):
4 sum = sum + int(n % 10)
5 n = int(n/10)
6 return sum
1function digSum(n) {
2 let sum = 0;
3 let str = n.toString();
4 console.log(parseInt(str.substring(0, 1)));
5 for (let i = 0; i < str.length; i++) {
6 sum += parseInt(str.substring(i,i+1));
7
8 }
9 return sum;
10}