forEach loop in JavaScript - example 1

by danielkwood

HTML

<html>
    <head>
        <title>forEach loops</title>
        <script src="script.js"></script>
    </head>
        
    <body>
    </body>
</html>

JavaScript

var myArray = ["one", "two", "three", "four"];

myArray.forEach(myFunction);

function myFunction(element) {
   // code in loop goes here
  console.log(element);
}