JSFiddle - React, Tailwind, and code Playground

by Eugen Sunic

JavaScript

function isOverlap(a, b) {
   const [min1, max1] = a
   const [min2, max2] = b
   if ((max1 >= min2 && max1 <= max2) || (max2 >= min1 && max2 <= max1)) {
     return true;
   }
   return false;
 }

 console.log(isOverlap([1, 3], [2, 6]))
 console.log(isOverlap([8, 10], [15, 18]));
 console.log(isOverlap([1, 1], [1, 1]));
 console.log(isOverlap([1, 4], [2, 3]));