Skip to content

Instantly share code, notes, and snippets.

@silavsale
Created February 10, 2020 03:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save silavsale/1a8c52998472835da1f7785478c75b4b to your computer and use it in GitHub Desktop.
Save silavsale/1a8c52998472835da1f7785478c75b4b to your computer and use it in GitHub Desktop.
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