Skip to content

Instantly share code, notes, and snippets.

@umairqazi523
Created September 21, 2020 14:23
Show Gist options
  • Save umairqazi523/a15e89051f0d8a6649b684cf32f647c9 to your computer and use it in GitHub Desktop.
Save umairqazi523/a15e89051f0d8a6649b684cf32f647c9 to your computer and use it in GitHub Desktop.
let int = -543;
console.log(reverseInt(int));
function reverseInt(integer) {
const reversed = integer.toString().split('').reverse().join('');
return Math.sign(integer) * parseInt(reversed);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment