This commit is contained in:
Philippe Torrel
2026-07-01 09:40:35 +02:00
parent f642829cb1
commit 2dbadb9c4f
11 changed files with 222 additions and 24 deletions

View File

@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="de">
<head>
<meta charset="UTF-8" />
@@ -24,6 +24,18 @@
</main>
<script>
'use strict';
const distance = ({ x: xOrigin, y: yOrigin }, { x: xDest, y: yDest }) => {
return Math.sqrt((yDest - yOrigin) ** 2 + (xDest - xOrigin) ** 2);
};
// RECOMMENDED without destructuring
const getDistance = (origin, dest) => {
return Math.sqrt((dest.y - origin.y) ** 2 + (dest.x - origin.x) ** 2);
};
console.log('Die Distanz beträgt: ', distance({ x: 1, y: 1 }, { x: 5, y: 1 }));
console.log('Die Distanz beträgt: ', getDistance({ x: 1, y: 1 }, { x: 5, y: 1 }));
</script>
</body>
</html>