title: Uncaught TypeError: String is not a function
body: <p>I am new to JavaScript and as part of my project for college I need to include some. I created a simple .js file and linked it to my index.html file using <code>&lt;script src="main.js"&gt;&lt;/script&gt;</code>   </p>
  
  <p>I created another page called <code>sellYourHome.html</code> and added a <code>&lt;section&gt;</code> tag with a table and created a simple form that calculates a comission and displays the results back in the input field.</p>
  
  <pre><code>function comCalc()
  {
   prcHouse = parseFloat(document.getElementById('prcHouse').value);
   commision =  0.25; 
   result = prcHouse * commision;
   document.getElementById('prcHouse').value = result.toString();
  }
  </code></pre>
  
  <p>That worked. </p>
  
  <p>Now under that function, I wanted to create another one that picks up a <code>&lt;div&gt;</code> element and changes the <code>background-color</code> to, say, blue.</p>
  
  <p>So I created a form on <code>index.html</code> and linked the same .js file to it in the same way.</p>
  
  <p>This is my HTML:</p>
  
  <pre><code>&lt;div id="mainContent"&gt;
      &lt;p&gt;hello&lt;/p&gt;
      &lt;form id="bgColor"&gt;
          &lt;table&gt;
              &lt;tr&gt;
                  &lt;td&gt;
                      &lt;input type="button" value="blue" onclick="bgColor('blue');"&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
      &lt;/form&gt;&lt;!-- end of bgColor Form--&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>My javascript is like so:</p>
  
  <pre><code>function comCalc()
  {
      prcHouse = parseFloat(document.getElementById('prcHouse').value);
      commision =  0.25;  
      result = prcHouse * commision;
      document.getElementById('prcHouse').value = result.toString();
  }
  
  function bgColor(color)
  {
    var div = document.getElementById('mainContent');
    div.style.background=color;  
  }
  </code></pre>
  
  <p>When I run this, I get this error on the console:</p>
  
  <blockquote>
    <p>Uncaught TypeError: String is not a function</p>
  </blockquote>
  
  <p>I am running this in a browser called SWRIron (which is based on Chrome and is HTML5-complient).</p>
  
  <p>What am I doing wrong?</p>