Advertisement
Spocoman

08. Point on Rectangle Border

Dec 22nd, 2021 (edited)
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function pointOfRectangleBorders(input) {
  2.     let x1= Number(input[0]);
  3.     let y1= Number(input[1]);
  4.     let x2= Number(input[2]);
  5.     let y2= Number(input[3]);
  6.     let x = Number(input[4]);
  7.     let y = Number(input[5]);
  8.  
  9.     let firstCondition = (x === x1 || x === x2) && (y >= y1 && y <= y2);
  10.     let secondCondition = (y === y1 || y === y2) && (x >= x1 && x <= x2);
  11.  
  12.     if (firstCondition || secondCondition) {
  13.         console.log('Border');
  14.     } else {
  15.         console.log('Inside / Outside');
  16.     }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement