Open this example in the interactive library
Source code
const overlap = ([a, b], [c, d]) =>
Math.max(0, Math.min(b, d) - Math.max(a, c));
console.log(overlap([10, 16], [13, 20]));
Sample output
3

Open this example in the interactive library
const overlap = ([a, b], [c, d]) =>
Math.max(0, Math.min(b, d) - Math.max(a, c));
console.log(overlap([10, 16], [13, 20]));
3