title: Streamline Javascript to calculate ranges
body: <p>I have a bit of javascript that I am using to calculate the y-scale of a graph. I need to adjust the scale according to the value. This works but seems really verbose. Is there a more streamlined way to do this?</p>
  
  <pre><code>if (maxValue &lt;= 20000){
      chartMaxY = 20000
  }       
  if (maxValue &lt;= 10000){
      chartMaxY = 10000
  }       
  if (maxValue &lt;= 5000){
      chartMaxY = 5000
  }       
  if (maxValue &lt;= 2500){
      chartMaxY = 2500
  }
  if (maxValue &lt;= 1000){
      chartMaxY = 1000
  }
  if (maxValue &lt;= 500){
      chartMaxY = 500
  }       
  if (maxValue &lt;= 250){
      chartMaxY = 250
  }           
  if (maxValue &lt;= 100){
      chartMaxY = 100
  }   
  if (maxValue &lt;= 50){
      chartMaxY = 50
  }   
  if (maxValue &lt;= 10){
      chartMaxY = 10
  }   
  </code></pre>