getNextDirection = ({ railCount, currentRail, direction }) => {
  switch (currentRail) {
    case 0:
      // Go down if we're on top of the fence.
      return DIRECTIONS.DOWN;
    case railCount - 1:
      // Go up if we're at the bottom of the fence.
      return DIRECTIONS.UP;
    default:
      // Continue with the same direction if we're in the middle of the fence.
      return direction;
  }
}
Get next direction to move (based on the current one) while traversing the fence.

@param {object} params
@param {number} params.railCount - Number of rows in the fence
@param {number} params.currentRail - Current row that we're visiting
@param {Direction} params.direction - Current direction
@returns {Direction} - The next direction to take