Beginner JavaScript Tutorial – 34 – Cool Technique to Print Array Elements




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


43 responses to “Beginner JavaScript Tutorial – 34 – Cool Technique to Print Array Elements”

  1. Here is an even better way to do this:

    <!doctype html>
    <html>

    <head>

    <title>For-Each Loop</title>

    </head>

    <body>

    <script type="application/javascript">

    var stuff = ["apples", "pears", "bacon", "tuna", "ham"].sort();

    stuff.forEach(

    function(element) {

    window.document.write(element + "<br />");

    }

    );

    </script>

    </body>

    </html>

  2. Very useful! thanks for the tutorials Bucky 🙂 they're a great help! I've done your java ones, now I'm busy with these and they're actually helping me understand java better due to the in depth explanation of certain things. Thanks again!

  3. You are so predictable ;D

    "Let's just put 5 random words in this array:"
    Me: probably apples
    Bucky: "apples"
    Me: yeah! Now what? :S
    Bucky: "pears"
    Me: "ah okay, now bacon"
    Bucky: "bacon…"
    Me: "Hmm, tuna?"
    Bucky: "tuna…"
    Me: "Last but not least: ham"
    Bucky: "and ham."

    You never disappoint me!

Leave a Reply