I almost got it.

Can anyone find my bug?

It passes a bunch of tests but fails for this input:

[[560,248],[0,16],[30,250],[950,187],[630,277],[950,187],[-212,-268],[-287,-222],[53,37],[-280,-100],[-1,-14],[-5,4],[-35,-387],[-95,11],[-70,-13],[-700,-274],[-95,11],[-2,-33],[3,62],[-4,-47],[106,98],[-7,-65],[-8,-71],[-8,-147],[5,5],[-5,-90],[-420,-158],[-420,-158],[-350,-129],[-475,-53],[-4,-47],[-380,-37],[0,-24],[35,299],[-8,-71],[-2,-6],[8,25],[6,13],[-106,-146],[53,37],[-7,-128],[-5,-1],[-318,-390],[-15,-191],[-665,-85],[318,342],[7,138],[-570,-69],[-9,-4],[0,-9],[1,-7],[-51,23],[4,1],[-7,5],[-280,-100],[700,306],[0,-23],[-7,-4],[-246,-184],[350,161],[-424,-512],[35,299],[0,-24],[-140,-42],[-760,-101],[-9,-9],[140,74],[-285,-21],[-350,-129],[-6,9],[-630,-245],[700,306],[1,-17],[0,16],[-70,-13],[1,24],[-328,-260],[-34,26],[7,-5],[-371,-451],[-570,-69],[0,27],[-7,-65],[-9,-166],[-475,-53],[-68,20],[210,103],[700,306],[7,-6],[-3,-52],[-106,-146],[560,248],[10,6],[6,119],[0,2],[-41,6],[7,19],[30,250]]

```
var maxPoints = function(points) {
if (points.length <= 2) {
return points.length;
}
var lines = {};
for (var i = 0; i < points.length; i++) {
var point1 = points[i];
for (var j = i + 1; j < points.length; j++) {
var point2 = points[j];
var slope; // (y1-y2)/(x1-x2)
var xAxes; // 0
var yAxes; // y1-slope*x1 Derived from: (y1-y0)/(x1-x0)=slope
// Exception is x1 === x2
if (point1.x === point2.x) {
slope = 0;
xAxes = point1.x;
yAxes = 0;
} else {
slope = (point1.y - point2.y) / (point1.x - point2.x)
xAxes = 0;
yAxes = point1.y - slope * point1.x;
}
// Line = y axes + slope (unless it never hits y axes then we need x axes and slope = 0);
var line_key = xAxes + ':' + yAxes + ':' + slope;
// For each line remember all distinct the points we found.
// 2 points can both have same x/y values so remember indices.
lines[line_key] = lines[line_key] || [];
lines[line_key][i] = true;
lines[line_key][j] = true;
}
}
var pointsPerLine = Object.values(lines).map(function (v) {
return Object.values(v).length;
});
return Math.max.apply(this, pointsPerLine);
};
```