vladovip

Javascript_DistanceBetweenPoint_MoreExercise

Dec 20th, 2021
1,211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(x1, y1, x2, y2) {
  2.    
  3.     let distanceAB = ((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
  4.     let result = Math.sqrt(distanceAB);
  5.     console.log(result);
  6.  
  7. }
  8. solve(2.34, 15.66, -13.55, -2.9985);
  9.  
  10. /*
  11. Write a JS function that calculates the distance between two points by given x and y coordinates.
  12. The input comes as four number elements in the format x1, y1, x2, y2.
  13. Each pair of elements are the coordinates of a point in 2D space.
  14. The output should be returned as a result of your function.
  15. */
  16.  
Advertisement
Add Comment
Please, Sign In to add comment