Beginner JavaScript Tutorial – 32 – reverse, push, sort




Facebook – https://www.facebook.com/TheNewBoston-464114846956315/
GitHub – https://github.com/buckyroberts
Google+ – https://plus.google.com/+BuckyRoberts
LinkedIn – https://www.linkedin.com/in/buckyroberts
reddit – https://www.reddit.com/r/thenewboston/
Support – https://www.patreon.com/thenewboston
thenewboston – https://thenewboston.com/
Twitter – https://twitter.com/bucky_roberts

Original source


22 responses to “Beginner JavaScript Tutorial – 32 – reverse, push, sort”

  1. If you want to list your array elements as you sort, reverse, push the elements see below. Thanks Bucky for the lessons! Doh, you just covered this in lesson 34.

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8" />
    <title>JS Lesson 32</title>
    <script type="text/javascript">
    function listArray(myArray, header) {
    // list elements in array
    document.write(header + " list:<br />");
    for (x = 0; x < myArray.length; x++) {
    document.write("myArray[" + x + "]: " + myArray[x] + "<br />");
    }
    document.write("<hr /><br />");
    }
    </script>
    </head>
    <body>
    <h2>Lesson 32 – reverese, push, sort</h2>
    <hr />
    <script type="text/javascript">
    var pets = new Array("Daisy", "Moe", "Fluffy", "Truman");
    listArray(pets, "Pet");
    pets.sort();
    listArray(pets, "Pet (sorted)");
    pets.reverse();
    listArray(pets, "Pet (reversed)");
    pets.push("Abbey");
    listArray(pets, "Pet (push Abby)");
    </script>
    </body>
    </html>

  2. Hi, Bucky, I;m from Israel, thank you for your learn us, about lesson Tutorial No' 32, i have problem ' i could not printing it, something going wrong, even i cheeked it many time, and every thing type right without any mistake,… What could be a problem, and how can i solve it,,. Thank in advance,.

  3. Hey Mr bucky!!!
    I am a great fan of ur videos these r the best material for any beginner.
    thanku so much for ur work,but i have a question
    q)- Why do you print the array by using the join command instead we can just write
    document.write(array_name);
    and this will print the array as a string separated by commas;)
    sorry if u consider it as an offense doesnt mean it that way
    btw Thanku Soo much.

Leave a Reply