Advertisement
bebo231312312321

Untitled

Feb 2nd, 2024
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function validityChecker(x1, y1, x2, y2) {
  2.     function isValid(x1, y1, x2, y2) {
  3.         const distance = Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2));
  4.  
  5.         if (Number.isInteger(distance)) {
  6.             console.log(`{${x1}, ${y1}} to {${x2}, ${y2}} is valid`);
  7.         } else {
  8.             console.log(`{${x1}, ${y1}} to {${x2}, ${y2}} is invalid`);
  9.         }
  10.     }
  11.     isValid(x1, y1, 0, 0);
  12.     isValid(x2, y2, 0, 0);
  13.     isValid(x1, y1, x2, y2);
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement