10/5/2018 - 1:42 PM


Three ways to create arrays in HTML

<DOCTYPE html>
      <title> While and Do While Loops</title>

  //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];

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