sumOfDigits method

num sumOfDigits()

sum of digits Returns the sum of digits in the number.

Implementation

num sumOfDigits() {
  num sum = 0;
  var number = this;
  while (number > 0) {
    sum += number % 10;
    number = (number / 10).floor();
  }
  return sum;
}