title: JavaScript get the <title> element
body: <p>I am writing a script that will make the title tag switch messages every few seconds. </p>
  
  <p>I wrote the code but when I tried to run it, I got an error here:</p>
  
  <pre><code>title = document.getElementByTagName("title")
  </code></pre>
  
  <p>The error I am getting says: <code>TypeError: 'undefined' is not a function (evaluating 'document.getElementByTagName("title")')</code>.</p>
  
  <p>The <code>script</code> tag is below the <code>title</code> tag and inside my script tag I have this to make sure the page has fully loaded before the code is ran:</p>
  
  <pre><code>window.addEventListener("DOMContentLoaded", function(){
      //code
  </code></pre>
  
  <p>Why am I getting an error when I try to get the <code>title</code> tag?</p>
  
  <p>Thank you.</p>