<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">

    <title>Arrow function example</title>

  </head>

  <body>
    <script>
      let array = ['Chris', 'Bob', 'Mark', 'Paul'];

      // Old style syntax
      //
      // array.forEach(function(e, i, a) {
      //    var elem = document.createElement('p');
      //    elem.textContent = (i + 1) + '. ' + e;
      //    document.body.appendChild(elem);
      // });

      // Arrow function syntax
      array.forEach((e, i, a) => {
         const elem = document.createElement('p');
         elem.textContent = (i + 1) + '. ' + e;
         document.body.appendChild(elem);
      });
    </script>
  </body>
</html>
