This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user