Created
December 24, 2020 06:20
-
-
Save chetans9/a060f883d45947ea5d73b8cfbde10778 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
//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