Sum of Digits Between Two Numbers

Published by Matt in

Create a function that sums the total number of digits between two numbers, inclusive. For example, between the numbers 19 and 22 we have:

// 19, 20, 21, 22
(1 + 9) + (2 + 0) + (2 + 1) + (2 + 2) = 19

Examples

sumDigits(7, 8) ➞ 15

sumDigits(17, 20) ➞ 29

sumDigits(10, 12) ➞ 6

Notes

N/A

Watch a quick demo on how Edabit works.