var reverse = function(x) {
let xStr = String(Math.abs(x)).split('').reverse().join('');
let int = parseInt(xStr);
if(int > Math.pow(2, 31)) return 0;
if(x < 0) return -int;
return int;
};
/**
* @param {number} x
* @return {number}
*/
var reverse = function(x) {
const toArr = String(x).split('')
const store = []
if(toArr.length > 0) {
toArr.forEach((val) => {
if(val !== 0 && val !== '-') {
store.push(val)
}
if(val === 0) {
store.push(val)
}
if(val !== 0 && val == '-') {
store.push('-')
}
})
}
let reverse = 0
if(store.includes('-')) {
reverse = - + store.reverse().join('').replace('-', '')
}
if(!store.includes('-')) {
reverse = store.reverse().join('').replace('-', '')
}
return parseInt(reverse)
};
var reverse = function(x) {
let str = String(Math.abs(x)).split('').reverse().join('');
let int = parseInt(str);
if(int > Math.pow(2, 31) || int > Math.pow(2, 31) - 1) return 0;
return x < 0 ? -int : int;
};