code: function getMinMaxValuesXY(arr) {
      let maxValueX = Number.MIN_VALUE;
      let maxValueY = Number.MIN_VALUE;
      let minValueX = Number.MAX_VALUE;
      let minValueY = Number.MAX_VALUE;
      arr
        .forEach((d) => {
          if (d.x > maxValueX) {
            maxValueX = d.x;
          }
          if (d.x < minValueX) {
            minValueX = d.x;
          }
          if (d.y > maxValueY) {
            maxValueY = d.y;
          }
          if (d.y < minValueY) {
            minValueY = d.y;
          }
        });
        return {maxValueX, minValueX, maxValueY, minValueY};
    }
docs: Find minimum and maximum X and Y values in an array of
  XY coordinate objects