vinonaweil
Revenue Diversification Expert
2
MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1
300 XP
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.
The Complete Code
Copy and paste to your editor to try this simple tutorial. Enjoy coding.
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.
Download
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.
Download
You must upgrade your account or reply in the thread to view hidden text.