# How To Reverse A Number Using JavaScript

In this tutorial, we are going to learn on How To Reverse A Number Using JavaScript. This program runs that the user will type the desired number then the program will execute the script to reverse the given number from the user. Let's start with:

JavaScript

This script will use to reverse the given number.

`<script>var reverse_number =0; var num_value = parseInt(prompt("Type your number to Reverse: "));document.write("<br>");document.write("<h3>How To Reverse A Number Using JavaScript</h3>");document.write("<b style='color:blue;'>The Original Number is <b style='color:red;'>" + num_value + "</b> .</b><br />");while( num_value != 0 ){reverse_number = parseInt(reverse_number * 10);reverse_number = parseInt(reverse_number + (num_value%10));num_value = parseInt(num_value/10);}document.write("<b style='color:blue;'>The Reverse Number is <b style='color:red;'>" + reverse_number + "</b> .</b><br>");</script>`

## The Complete Code

Copy and paste to your editor to try this simple tutorial. Enjoy coding.

`<!DOCTYPE html> <html> <head> <title>How To Reverse A Number Using JavaScript</title> <style type="text/css">body {	width:500px;	margin:auto;	text-align:center;}h3 {	color:blue;}</style></head>  <body><script>var reverse_number =0; var num_value = parseInt(prompt("Type your number to Reverse: "));document.write("<br>");document.write("<h3>How To Reverse A Number Using JavaScript</h3>");document.write("<b style='color:blue;'>The Original Number is <b style='color:red;'>" + num_value + "</b> .</b><br />");while( num_value != 0 ){reverse_number = parseInt(reverse_number * 10);reverse_number = parseInt(reverse_number + (num_value%10));num_value = parseInt(num_value/10);}document.write("<b style='color:blue;'>The Reverse Number is <b style='color:red;'>" + reverse_number + "</b> .</b><br>");</script></body></html>`

Hope that this tutorial will help you a lot.

So what can you say about this work? Share your thoughts in the comment section below or email me at [email protected]. Practice Coding. Thank you very much.

### Tags

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.

Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.