Skip to Main Content

Reverse Integer

Problem URL:Reverse Integer

My Solution

JavaScript

/**
 * @param {number} x
 * @return {number}
 */

const reverse = (x) => {
  var n = Number(Math.abs(x).toString().split("").reverse().join(""));
  if (n > 0x7fffffff) return 0;
  else return x < 0 ? -n : n;
};

Let's Connect

Twitter GitHub LinkedIn