Sort an array alphabetically and ascending

A simple example of sorting an array alphabetically and ascending.
<!DOCTYPE html>
<html>
<head>
   
</head>
<body>

<script>
    
          var vehicles = ["Lamborghini", "Ferrari", "A-10 Thunderbolt", "F-16", "Mi-7", "T-34/85", "Titanic"];
          
              console.log("Before sort (vehicles) = " + vehicles);
		
              vehicles.sort();

              console.log("After sort (vehicles) = " + vehicles);
    
</script>

</body>
</html>

Responses

0 Replies