HOw to add count function to keep the amount of objects in my array while also using the alphabeticall function



  • <html>
    <body>

    <p>The sort() method sorts an array alphabetically.</p>

    <button onclick=“myFunction()”>Try it</button>

    <p id=“demo”></p>

    <script>
    var fruits = [“Banana”, “Orange”, “Apple”, “Mango”];
    document.getElementById(“demo”).innerHTML = fruits;

    function myFunction() {
    fruits.sort();
    document.getElementById(“demo”).innerHTML = fruits;
    }
    </script>

    </body>
    </html>



  • This is not a Notepad++ related question. Try a community or a message board related to JavaScript or simply Google for it, there’s tons of information out there.


Log in to reply