```
var reverse = function(x) {
var symbol = '+';
var arr = (x + '').split('');
if(arr[0] == '-'){
symbol = arr.shift();
}
arr = arr.reverse();
while(arr[0] == 0){
arr.shift();
}
arr.unshift(symbol);
var y = parseInt(arr.join(''));
return y >= -Math.pow(2,31) && y <= Math.pow(2,31) - 1 ? y : 0;
};
```