Skip to content

Instantly share code, notes, and snippets.

@chetans9
Created December 24, 2020 06:20
Show Gist options
  • Save chetans9/a060f883d45947ea5d73b8cfbde10778 to your computer and use it in GitHub Desktop.
Save chetans9/a060f883d45947ea5d73b8cfbde10778 to your computer and use it in GitHub Desktop.
//Reverse integer number without loop in Javascript
var num = 34562;
var reversed = 0;
while(num > 1){
var last_digit = num % 10;
reversed = reversed * 10 + last_digit;
num = parseInt(num/10);
}
console.log(reversed);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment