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>

View File

@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="de">
<head>
<meta charset="UTF-8" />
@@ -18,7 +18,16 @@
<script>
'use strict';
const reverseString = (str) => {};
const reverseString = (str) => {
if (str.length <= 1) {
return '';
}
// console.log('str.slice(1): ', str.slice(1));
// iwie kapier ich das mit den rückgabewarten von rekursiven funktionen noch net wirklich
return reverseString(str.slice(1)) + str[0];
// return ... <-- ("lo") + "l" <--- ("llo") + "e" <-- ("ello") + "h"
};
// Test cases
console.log(reverseString('hello')); // => "olleh"

View File

@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="de">
<head>
<meta charset="UTF-8" />
@@ -24,12 +24,15 @@
<script>
'use strict';
let logTransformedName = (firstName, lastName) => {
let logTransformedName = ({ firstName, lastName }) => {
console.log(`${lastName}, ${firstName.charAt(0)}.`);
};
logTransformedName('Ladislaus', 'Jones');
// TODO: Übergabe von einem Objekt
const trainer = { lastName: 'Torrel', firstName: 'Philippe' };
logTransformedName({ firstName: 'Ladislaus', lastName: 'Jones' });
logTransformedName(trainer);
logTransformedName({ lastName: 'Rohleder', firstName: 'Andreas', isSmoker: true });
</script>
</body>
</html>