Reverse Number  Program JavaScript

Reverse Number Program JavaScript

Top 10
16 Jul 2020
Give a thumbs up
2

Javascript Html


Introduce of java

JavaScript is a server client side language. And JavaScript is a general purpose programming language and class based programming language and object orientade programming language You can make animation and web application etc


Step-1 Create html file

<!Doctype>

<html>

<head>

<title>

Reverse number program 

</title>

</head>

<body>

<h1>Reverse number </h1>

</body>

</html>


Step-2 Create JavaScript file

function reversenber(n)

{

n = n + " ";

return n.split(" ").reverse().join(" ");

}

console.log(reversenumber);

Input number is: 215687


Sample Output:

This is Output: 786512


Work of split (), reverse (),join

 split() Split method is used to split a String object, into an array of strings by separating the string into substrings.

console.log([1234]);

Output:[ "1", "2", "3", "4"]

reverse() Reverse method is used to reverse an array in place.

console.log([ "1", "2", "3", "4"]);

Output:[ "4", "3", "2", "1"]

join() Join method is used to join all elements of an array into a string.

console.log( ["4", "3", "2", "1"]);

Output: 4321


Author
Top 10
Blogger Top 10 content related post

Post a comment
0 Comments: