← Back to challenges

Carrying the Digits

JavaScriptHardnumbersmathcontrol_flow

Instructions

Write a function that returns the number of times you must carry a digit when you sum together two integers.

Examples

carryDigits(36, 135) ➞ 1
// You carry the 1 when you sum 6 and 5 together.

carryDigits(671, 329) ➞ 3

carryDigits(1111, 3333) ➞ 0

carryDigits(53214, 56905) ➞ 3

Notes

Count all carry operations (even those on leading digits).

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.