Created
September 21, 2020 14:23
-
-
Save umairqazi523/a15e89051f0d8a6649b684cf32f647c9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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