Skip to content

Instantly share code, notes, and snippets.

@spektraldevelopment
Created September 18, 2018 14:56
Show Gist options
  • Select an option

  • Save spektraldevelopment/85e503869441e0da249e7a7b23d172c0 to your computer and use it in GitHub Desktop.

Select an option

Save spektraldevelopment/85e503869441e0da249e7a7b23d172c0 to your computer and use it in GitHub Desktop.
JS: Reverse Int
function reverseInt(n) {
const sign = Math.sign(n);
const revNum = parseInt(n.toString().split('').reverse().join(''));
return sign * revNum;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment