Summate() - Add the characters of a number

/ Published in: JavaScript
Save to your folder(s)

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


RSS Icon Subscribe to comments

You need to login to post a comment.