Following the many suggestions for a grid layout in gardening, I've created a mockup to demonstrate the idea
https://jsfiddle.net/6yexyfqu/27/
uses this fomula
Code:
var snapInt2Grid = function(/*number*/ int, /*number*/ gridSize) {
var remainder = int % gridSize;
return int - remainder;
}
A nice thing about a modulo (%) based formula, is that you don't have to do distance checking between plants. Since all plants are snapped to the same grid, you just check to see if an entity is in the exact same spot that you are about to place the plant.
Though considering how the engine works, doing distance detection for entities in a certain radius might be easier to implement than looping through an array of entities manually.