```
var numberOfBoomerangs = function(points) {
let result = 0;
points.forEach((i)=> {
let distMap = {};
points.forEach((j)=> {
if(i!==j) {
let dist = (i[0]-j[0])*(i[0]-j[0]) + (i[1]-j[1])*(i[1]-j[1]);
let prevDist = distMap[dist] || 0;
result += 2*prevDist;
distMap[dist] = prevDist+1;
}
});
});
return result;
```

};