title: Checking for range overlap
body: <p>I am trying to implement a function which, when given two objects that represent lines, returns whether they overlap or not.</p>
  
  <p>Here is how it should look like visually.</p>
  
  <p>Example 1:</p>
  
  <pre><code>checkOverlap({start: 0, end: 10}, {start: 8, end: 15})
  </code></pre>
  
  <p>Which visually, would be:</p>
  
  <pre><code>0--------10
       8-------15
         ^ overlap
  </code></pre>
  
  <p>returns <code>true</code>.</p>
  
  <p>Example 2:</p>
  
  <pre><code>checkOverlap({start: 12, end: 15}, {start: 0, end: 10})
  </code></pre>
  
  <p>Which visually, would be:</p>
  
  <pre><code>             12-------15   
  0--------10
  
                no overlap
  </code></pre>
  
  <p>returns <code>false</code>.</p>
  
  <p>Here is my function which works for some but not all:</p>
  
  <pre><code>function checkOverlap(lineA, lineB) {
      var result;
      for(var a in lineA) {
          for(var b in lineB) {
              if(a.end &gt; b.start) {
                  result = true;
              } else {
                  result = true;
              }
          }
      }
      return result;
  }
  </code></pre>