Prosen-Ghosh / sum-digit

Sum the digits of a number.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

sum-digit

Sum the digits of a number.

npm license github-issues

travis-status stars forks

Features

Install

npm install --save sum-digit

Usage

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

Author

Prosen Ghosh prosenghosh25@gmail.com (https://bd.linkedin.com/in/prosen-ghosh-baba9aa8)

License

  • MIT

About

Sum the digits of a number.

License:MIT License


Languages

Language:JavaScript 100.0%