This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Write a program to find out if two rectangles R1 and R2 are overlapping? | |
const overlappingRectangle = ( | |
R1x1, | |
R1x2, | |
R1y1, | |
R1y2, | |
R2x1, | |
R2x2, | |
R2y1, | |
R2y2 | |
) => { | |
if (R1x2 < R2x1 || R1x1 > R2x2) { | |
return false; | |
} | |
if (R1y2 < R2y1 || R1y1 > R2y2) { | |
return false; | |
} | |
return true; | |
}; | |
console.log(overlappingRectangle(2, 4, 5, 10, 3, 11, 5, 12)); |
Author
ShilpiMaurya
commented
Jan 3, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment