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