JavaScript Program to reverse a number
In this program, You will learn how to reverse a number in JavaScript.
while(condition){
//statement
increment/decrement
}
![JavaScript Program to reverse a number](https://xiith.com/wp-content/uploads/2020/07/Reverse-a-Number-1.png)
Example: How to reverse a number in JavaScript
let n = parseInt(prompt("Enter a number"))
let rev = 0, r;
rev = 0;
while (n > 0) {
r = n % 10;
rev = rev * 10 + r;
n = parseInt(n / 10)
}
console.log("Reverse number is:" + rev)
Output:
Enter a number> 153
Reverse number is:351