This commit is contained in:
Philippe Torrel
2026-09-23 10:47:07 +02:00
parent b16dd8458d
commit 082a9bd7b3
11 changed files with 209 additions and 18 deletions
+12 -1
View File
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="de">
<head>
<meta charset="UTF-8" />
@@ -24,6 +24,17 @@
</main>
<script>
'use strict';
const distance = ({ x: xOrigin, y: yOrigin }, { x: xDestination, y: yDestination }) => {
return Math.sqrt((yDestination - yOrigin) ** 2 + (xDestination - xOrigin) ** 2);
};
const getDistance = (origin, target) => {
return Math.sqrt((target.y - origin.y) ** 2 + (target.x - origin.x) ** 2);
};
console.log(distance({ x: 1, y: 1 }, { x: 5, y: 1 })); // => 4
console.log(getDistance({ x: 1, y: 1 }, { x: 5, y: 1 })); // => 4
</script>
</body>
</html>