gskorchev

point in rectangle

Jan 28th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function pointInRectangle(input) {
  2.     let x1 = Number(input.shift());
  3.     let y1 = Number(input.shift());
  4.     let x2 = Number(input.shift());
  5.     let y2 = Number(input.shift());
  6.     let x = Number(input.shift());
  7.     let y = Number(input.shift());
  8.     if ((y >= y1) && (y <= y2) && (x >= x1) && (x <= x2)) {
  9.         console.log("Inside");
  10.     } else {
  11.         console.log("Outside");
  12.     }
  13. }
  14.  
  15. pointInRectangle([-1, -3, 4, 1, 0.5, 1]);
Advertisement
Add Comment
Please, Sign In to add comment