
Hi dear welcome to "CodePrime" Blog . In this post you are going to learn Array Methods Sort & Reverse Function Uses In JavaScript . First Creat A index.html file Copy This HTML CODE and pest it one your code editor. 2ndly creat sort-and-reverse.js file Then Copy The JS CODE and pest it then open the index.html file with your browser.
HTML CODE
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="/sort-and-reverse.js"></script>
<title>javascript</title>
</head>
<body >
<h2>Javascript Tutorial <br>By Codeprime</h2>
</body>
</html>
JAVASCRIPT CODE
var a = ["Hanif", "Rubia", "Hassan", "Abbas"];
document.write(a + "<br><br>");
///sort order function
a.sort();
document.write(a + "<br><br>");
///reverse order function
a.reverse();
document.write(a + "<br>");
0 Comments