For example: I have a grid where each square is identified by a value denoting row and column, eg: 32 is in the 3rd column and 2nd row. Nearby locations would be squares 31, 33, 41, 42, 43, 21, 22, 23.
if (main.location === player.location - 1 ||
main.location === player.location + 1 ||
main.location === player.location - 9 ||
main.location === player.location + 9 ||
main.location === player.location - 10 ||
main.location === player.location + 10 ||
main.location === player.location - 11 ||
main.location === player.location + 11) {
console.log("player is nearby");
}