title: Get x intercept given two points
body: <p>This might be a somewhat simple question but I can not seem to get it working.</p>
  
  <p>I want to find the x intercept given two points.</p>
  
  <p>Lets say I have these two points:
  (5,3) and (3,4)
  I would like to find the x intercept.
  Currently this is what I have. Which finds the y intercept correctly. In this case 5.5.</p>
  
  <pre><code>var A = [5, 3];
  var B = [3, 4];
  
  function slope(a, b) {
      if (a[0] == b[0]) {
          return null;
      }
  
      return (b[1] - a[1]) / (b[0] - a[0]);
  }
  
  function intercept(point, slope) {
      if (slope === null) {
          // vertical line
          return point[0];
      }
  
      return point[1] - slope * point[0];
  }
  
  var m = slope(A, B);
  console.log(m);
  
  var b = intercept(A, m);
  console.log('intercept: ' + b);
  </code></pre>