JSFiddle - React, Tailwind, and code Playground

JavaScript

var reverse = function(x) {
	// Get positive or negative sign
	var sign= (x > 0) ? 1 : -1;
  
  // convert number to positive
	x = Math.abs(x);
  
  // convert number to array of strings, then reverse it
	var str = x.toString().split("").reverse().join("");
  
  // add sign to str
	var result = sign * +str;
  console.log(result)
	if (result > 2147483647 || result < -2147483648) return 0;
	else return result;
};

console.log(reverse(2147483646))