Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
The first step is to loop over the digits. We can convert the integer into a string, an array of digits, or just loop over its digits.
Keep a variable sign that initially equals 1 and a variable answer that initially equals 0.
Each time you loop over a digit i, add sign * i to answer, then multiply sign by -1.