Use the sort() method to sort the array alphabetically. - Javascript Array

Javascript examples for Array:Quiz

Description

Use the sort() method to sort the array alphabetically.

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<p id="demo"></p>

<script>
var myArray = ["Javascript", "HTML", "CSS", "SVG"];
myArray.sort();/*from  w  ww  . java  2s  .  com*/
document.getElementById("demo").innerHTML = myArray;
</script>

</body>
</html>

Related Tutorials