Advertisement
Spocoman

Point Of Segment(Ternary Operator)

Oct 1st, 2023
1,200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function pointOfSegment(input) {
  2.     let first = Number(input[0]);
  3.     let second = Number(input[1]);
  4.     let point = Number(input[2]);
  5.    
  6.     console.log(point <= first && point >= second || point >= first && point <= second ? "in" : "out");
  7.     console.log(Math.min(Math.abs(first - point), Math.abs(second - point)));
  8.  
  9.     return;
  10. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement