number. Put signs in front of its digits starting from the leftmost one: the first digit gets a plus, the second a minus, the third a plus again, and so on, alternating.
Return the sum of the digits with those signs.number=7302 → 2
(+7) + (−3) + (+0) + (−2) = 2.
number=4 → 4
A single digit, taken with a plus sign.
number=1919 → -16
1 − 9 + 1 − 9 = −16: the answer can be negative.
number=7302
2
Run checks the first 3 tests in your browser. Submit checks all 39 tests on the server, hidden ones included.