nick34992
6/1/2017 - 5:42 AM

HTML, JavaScript: concat()

HTML, JavaScript: concat()

<!DOCTYPE html>
<html>
  <head>
    <style>
      code {
        background-color: LightGrey;
      }
    </style>
  </head>
  <body>

    <p>Concatinate three following arrays:</p>
    <p>
      <code>
        var north = ["Ainsley", "Baxter"];<br>
        var east = ["Cara", "Daniel"];<br>
        var south = ["Elaine", "Frank"];
      </code>
    </p>

    <button onclick="myFunction()">Concatinate</button>

    <p id="demo"></p>

    <script>
      function myFunction() {
        var north = ["Ainsley", "Baxter"];
        var east = ["Cara", "Daniel"];
        var south = ["Elaine", "Frank"];
        var people = north.concat(east, south);
        document.getElementById("demo").innerHTML = people;
      }
    </script>

  </body>
</html>