Created
February 10, 2020 03:05
-
-
Save silavsale/1a8c52998472835da1f7785478c75b4b 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
var reverse = function(x) { | |
let i; | |
let y = ''; | |
let numLen = x.toString().length; | |
let firstNum = x.toString().slice(0, 1); | |
if (firstNum === '-'){ | |
y = '-'; | |
x = x.toString().slice(1, numLen); | |
} | |
for(i = numLen; i > 0 ; i--){ | |
y += x.toString().slice(i-1, i); | |
} | |
return y; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment