title: How would I change the background color of an HTML file if the screen size is too small using a javascript function?
body: <p>How would I change the background color of an HTML file if the screen size is too small using a javascript function? For example I need the background of my HTML file to be gray but if the window size is less than 600px it turns red. I did it with CSS but need to do it in java script. Here is what I have in CSS </p>
  
  <pre><code>&lt;style&gt; 
  body {     
    background-color: gray; 
  }  
  @media screen and (max-width: 600px) {     
    body {        
      background-color: red;     
    } 
  } 
  &lt;/style&gt;
  </code></pre>