JSFiddle - React, Tailwind, and code Playground

HTML

<canvas width="250" height="250" id="rectCanvas"></canvas>

JavaScript

// Define data structures
var ctx, rectToDraw, i;

const 
    r1 = {x1: 10, x2: 80, y1: 10, y2: 80},
    r2 = {x1: 60, x2: 100, y1: 60, y2: 100},
    r3 = {x1: 90, x2: 180, y1: 90, y2: 140},
    r4 = {x1: 120, x2: 140, y1: 130, y2: 160},
    r5 = {x1: 160, x2: 210, y1: 80, y2: 110},
    myRects = {r1: r1, r2: r2, r3: r3, r4: r4, r5: r5};

// Define functions that act on data structures

function doRectanglesIntersect(r1, r2) {
  return (r1.x1 <= r2.x2 &&
          r2.x1 <= r1.x2 &&
          r1.y1  <= r2.y2 &&
          r2.y1  <= r1.y2)
}

function recursivelyGetIntersectingRects(rect) {
    // Code goes here
}

console.log(recursivelyGetIntersectingRects(r1)); // Should return [r2,r3,r4,r5]

// Aside: Draw rects on canvas as visual aid

ctx = document.getElementById('rectCanvas').getContext('2d');

for(i in myRects) {
    rectToDraw = myRects[i];
    
    ctx.rect(
        rectToDraw.x1, 
        rectToDraw.y1,
        rectToDraw.x2 - rectToDraw.x1,
        rectToDraw.y2 - rectToDraw.y1
    );
    
    ctx.stroke();
}