Created
January 5, 2021 16:36
-
-
Save Jagathishrex/268c9f6f331ab81d0b23b418c265aca2 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
function reverseInt(n) { | |
let reversedInteger = n.toString().split('').reverse().join(''); | |
return parseInt(reversedInteger) * Math.sign(n); | |
} | |
console.log(reverseInt(-12)); // -21 | |
console.log(reverseInt(-1)); // -1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment