Get your own website Result Size: 625 x 565
x
 
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Arrays</h2>
<p>The Array.sort() method sorts the elements of an array.</p>
<p>The Array.reverse() method reverses the order.</p>
<p id="demo"></p>
<script>
const fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.sort();
fruits.reverse();
document.getElementById("demo").innerHTML = fruits;
</script>
</body>
<!-- Mirrored from www.w3schools.com/jsref/tryit.asp?filename=tryjsref_sort4 by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 21 Dec 2022 17:39:07 GMT -->
</html>