reverse = function(x, result = 0) {
    while (x !== 0) {
        const digit = (x % 10)

        if (isOutOfBounds(digit, result)) return 0;

        x = Math.trunc(x / 10);
        result = (result * 10) + digit;
    }

    return result;
}
https://leetcode.com/problems/reverse-integer/
Time O(log(x)) | Space O(1)
@param {number} x
@return {number}