Advertisement
Martin_D24

Untitled

Feb 24th, 2025
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(x1, x2, y1, y2){
  2.     let distance = (x1, y1, x2, y2) => Math.sqrt((x2-x1)**2 + (y2-y1)**2);
  3.  
  4.     console.log(`{${x1}, ${y1}} to {0, 0} is ${Number.isInteger(distance(x1, y1, 0, 0)) ? 'valid' : 'invalid'}`);
  5.     console.log(`{${x2}, ${y2}} to {0, 0} is ${Number.isInteger(distance(x2, y2, 0, 0)) ? 'valid' : 'invalid'}`);
  6.     console.log(`{${x1}, ${y1}} to {${x2}, ${y2}} is ${Number.isInteger(distance(x1, y1, x2, y2)) ? 'valid' : 'invalid'}`);
  7. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement