Summate() - Add the characters of a number


/ Published in: JavaScript

This function will return the sum of the characters making up a number. For example, summate(321) will return 6. summate(123) will also return 6, because both 123 and 321 are made out of the same characters. Supports integers of any length, but only positive ones. Negatives get weird. Non-integers get rounded.

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.