Help! Circles of given radius through two points

Tell us what’s happening:
I dont know why my code cannot fulfill last objective: getCircles([0.1234, 0.9876], [0.8765, 0.2345], 2.0) should return [[1.8631, 1.9742], [-0.8632, -0.7521]] .

Your code so far


function getCircles (...args) {
  var p1x = args[0][0];
  var p1y = args[0][1];
  var p2x = args[1][0];
  var p2y = args[1][1];
  var r = args[2];

  if(p1x == p2x && p1y == p2y && r > 0){
    return 'Coincident point. Infinite solutions';
  }

  if(p1x == p2x && p1y == p2y && r == 0){
    return 'Radius Zero';
  }
  
  var distance = 0;
  distance = Math.pow(Math.pow(p1x-p2x,2)+Math.pow(p1y-p2y,2),0.5);

  if(2*r < distance){
    return 'No intersection. Points further apart than circle diameter';
  }

  if(2*r == distance){
    return [(p1x+p2x)/2,(p1y+p2y)/2];
  }
  
  var output = [[], []];

  var x3 = (p1x+p2x)/2;
  var y3 = (p1y+p2y)/2;
  var q = distance;
  var x = x3 + Math.sqrt(Math.pow(r,2)-Math.pow(q/2,2))*(p1y-p2y)/q;
  var y = y3 + Math.sqrt(Math.pow(r,2)-Math.pow(q/2,2))*(p2x-p1x)/q;
  
  output[0].push(x.toFixed(4));
  output[0].push(y.toFixed(4));

  x = x3 - Math.sqrt(Math.pow(r,2)-Math.pow(q/2,2))*(p1y-p2y)/q;
  y = y3 - Math.sqrt(Math.pow(r,2)-Math.pow(q/2,2))*(p2x-p1x)/q;

  output[1].push(x.toFixed(4));
  output[1].push(y.toFixed(4));
  
  
  return output;
}

getCircles([0.1234, 0.9876], [0.8765, 0.2345], 2.0)

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36.

Link to the challenge:

@hk4465ty,

since I am not going to debug your code for you, I highly recommend you do.
I would add some console.log statements to your code and see where the code seems to fail.