Sum the digits of a number.
npm install --save sum-digit
const sumDigit = require('sum-digit');
sumDigit(123);
//=> 6
sumDigit(32581);
//=> 19
sumDigit('123');
//=> 6
sumDigit('123x');
//=> NaN
sumDigit(); // without parameter this function will throw a type error
//=> TypeError: expects Numeric value got undefined
Prosen Ghosh prosenghosh25@gmail.com (https://bd.linkedin.com/in/prosen-ghosh-baba9aa8)
- MIT