matt2099
10/5/2018 - 1:42 PM

Arrays

Three ways to create arrays in HTML

<DOCTYPE html>
<html>
  <head>
      <title> While and Do While Loops</title>
    </head>
<body>
  <script>

  //Three ways to declare arrays.
    var airlines = new Array();
    airlines[0] = "Delta";
    airlines[1] = "British Airways";
    airlines[2] = "American Airlines";
    airlines[3] = "Virgin";
    airlines[4] = "Easyjet";
    airlines[5] = "Jet2";
    airlines[6] = "Ryanair";

    var family = new Array("Mark", "Brett", "Kerry", "Joan", "Rick");

    var states = ["New York", "Texas", "Washington", "Vermont", "Connecticue"];

    function output()
    {
      document.getElementById('output').innerHTML = airlines[0] + "<br/>" + family[0] + "<br/>" + states[0];
    }


  </script>
  <p id= "output"></p>
  <button onclick="output()">output</button>
</body>
</html>