Question: I am wondering how I can create an array of coordinates around specific x, y.
For example:

```
xxxxx
xxoxx
xxxxx

```

"o" is on coordinates 3, 2 in this case
Now I want to output:

```
xxx
xox
xxx

```

as an Array of coordinates around "o" which is on 3, 2

Answer: 
I did exactly that in a minesweeper implementation in Vue.js:

```
getNeighbours (field) {
  let list = []
  let minX = Math.max(0, field.x - 1)
  let maxX = Math.min(this.getX - 1, field.x + 1)
  let minY = Math.max(0, field.y - 1)
  let maxY = Math.min(this.getY - 1, field.y + 1)
  for (let x = minX; x <= maxX; x++) {
    for (let y = minY; y <= maxY; y++) {
      if (x !== field.x || y !== field.y) {
        list.push(this.map[y][x])
      }
    }
  }
  return list
},

```

Where `this` is the playfield with `this.X` columns and `this.Y` rows. The whole playfield is held in a two-dimensional array `this.map[y][x]`.

You can check here: <https://github.com/franktopel/vue-defuse>

The method can be found here: <https://github.com/franktopel/vue-defuse/blob/master/src/components/VueDefuse.vue#L477>
The code below does not account for any error handling if you enter an `xPos` or `yPos` that is on the border.

```js
var fullArray = [['x','x','x','x','x'],['x','x','o','x','x'],['x','x','x','x','x']],
  xPos = 2,
  yPos = 1;
for (var y = yPos-1; y <= yPos + 1; y++) {
  console.log(fullArray[y][xPos-1],fullArray[y][xPos],fullArray[y][xPos+1]);
}
```