title: Using Javascript to Alternate background color of HTML element
body: <p>So I have a practise test that asks me to change the background color and text color of a paragraph section with id "fourth" from black background and white text to vise versa and reverse every 30 seconds preferably by using if/else statements. But for some reason my If statement (and probably my else statement) does not work.</p>
  
  <p>the code i have so far is this:</p>
  
  <p>HTML</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;link href="teststyle.css" rel="stylesheet" type="text/css"/&gt;
  &lt;script src="flash.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div id="first"&gt;
  mares eat oats
  &lt;/div&gt;
  &lt;h1 id="second"&gt;
  and does eat oats
  &lt;/h1&gt;
  &lt;p id="third"&gt;
  and little lambs eat ivy
  &lt;/p&gt;
  &lt;p id="fourth"&gt;
    Mirthipan Karunakaran
  &lt;/p&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>CSS</p>
  
  <pre><code>#first {
   text-align: center;
  }
  
  #second {
    color: green;
    text-align: left;
  }
  
  #third {
    color: orange;
    text-align: right;
  }
  
  #fourth {
    color: white;
    background-color: black;
  }
  </code></pre>
  
  <p>JAVASCRIPT</p>
  
  <pre><code>function updatePage(){
  
  var name = document.getElementById("fourth");
  
  if(name.style.backgroundColor == "black") {
   name.style.backgroundColor = "pink";
  
    } else {
    name.style.backgroundColor = "purple";
  }
  
  }
  
  function startUpdate(){
    updatePage();
    window.setInterval(updatePage,10 * 1000);
  }
  
  window.onload=startUpdate;
  </code></pre>
  
  <p>How would I go about making this work?</p>