3 ms·
This looks like buggy JavaScript. The cohesion() function in the script element at the end of the post is a little different than the calculateCohesion() funct
by SloopJon 8y ago
This looks like buggy JavaScript. The cohesion() function in the script element at the end of the post is a little different than the calculateCohesion() function described in the post:
var averagePosition;
if (count > 0) {
averagePosition = {
x: positionSum.x / count,
y: positionSum.y / count
};
} else {
return {x: 0, y:0};
}