diff --git a/02_advanced/agenda.md b/02_advanced/agenda.md index 6a83181..fd6671c 100644 --- a/02_advanced/agenda.md +++ b/02_advanced/agenda.md @@ -188,12 +188,10 @@ Abschlussquiz - JS Grundlagen - Destructuring von Objekten und Arrays - Rekursion -- Promises -- Callback-Hell **Übungen:** -Übung 01 - 08 +Übung 01 - 10 --- @@ -201,8 +199,9 @@ Abschlussquiz - JS Grundlagen **Inhalt:** +- Promises +- Callback-Hell - Installation von node (npm) und Windows Terminal (für Node) -- **Exkurs: Switch Case Abfragen** - **Exkurs: Statische Webseite mit Sass und HTML** - **Exkurs: Versionierung mit Github Part I** @@ -234,6 +233,7 @@ Abschlussquiz - JS Grundlagen - commonjs vs esm - async await - Promise.all() +- **Exkurs: Switch Case Abfragen** - **Exkurs: Statische Webseite mit Sass und HTML** - **Exkurs: Versionierung mit Github Part I** - 1:1 Meeting diff --git a/02_advanced/uebungen/#u02_distance/index.html b/02_advanced/uebungen/#u02_distance/index.html index 6d8656b..0e9bad2 100644 --- a/02_advanced/uebungen/#u02_distance/index.html +++ b/02_advanced/uebungen/#u02_distance/index.html @@ -1,4 +1,4 @@ - +
@@ -24,6 +24,18 @@ diff --git a/02_advanced/uebungen/#u07_string-rekursiv/index.html b/02_advanced/uebungen/#u07_string-rekursiv/index.html index 18d2ac1..9690a36 100644 --- a/02_advanced/uebungen/#u07_string-rekursiv/index.html +++ b/02_advanced/uebungen/#u07_string-rekursiv/index.html @@ -1,4 +1,4 @@ - + @@ -18,7 +18,16 @@ diff --git a/02_advanced/unterricht/tag12/01_csv-to-obj.html b/02_advanced/unterricht/tag12/01_csv-to-obj.html index 2c20df4..75f5e54 100644 --- a/02_advanced/unterricht/tag12/01_csv-to-obj.html +++ b/02_advanced/unterricht/tag12/01_csv-to-obj.html @@ -26,13 +26,17 @@ // Funktionen const convertCsvToObj = (csv = '') => { - const rows = csv - .split('\n') // => ['name, category, price', 'Klingon Letter...'] - .slice(1) // => [' Klingon Letter Opener, Office Warfare, 19.99', ...] + const rows = csv.split('\n'); // => ['name, category, price', 'Klingon Letter...'] + + const headerRow = rows.shift().split(/\s*,\s*/); // Abgespeichert, falls man es noch benötigt + + console.log(headerRow); // => ['name', 'category', 'price'] + + const productRows = rows .map((row) => row.trim()) // "white spaces" des Strings werden entfernt .filter((row) => row !== ''); // leere Einträge werden rausgefiltert - const ar = rows.map((row) => { + const ar = productRows.map((row) => { const fields = row.split(/\s*,\s*/); // => ['Klingon Letter Opener', 'Office Warfare', '19.99', ...] // const name = fields[0]; diff --git a/02_advanced/unterricht/tag12/02_destructuring.html b/02_advanced/unterricht/tag12/02_destructuring.html index 5f0cd12..cc4e68f 100644 --- a/02_advanced/unterricht/tag12/02_destructuring.html +++ b/02_advanced/unterricht/tag12/02_destructuring.html @@ -73,6 +73,7 @@ // Destructuring eines Objektes mit Defaultparametern und Umbenennung const { controls = true, showDots: dots, mode = 'gallery', container: el } = options; + // logic code wird kürzer durch destructuring const slider = el; // options.container if (controls) { diff --git a/02_advanced/unterricht/tag12/04_destructuring-with-rest-operator.html b/02_advanced/unterricht/tag12/04_destructuring-with-rest-operator.html index 63bd3fa..6a61ac9 100644 --- a/02_advanced/unterricht/tag12/04_destructuring-with-rest-operator.html +++ b/02_advanced/unterricht/tag12/04_destructuring-with-rest-operator.html @@ -49,7 +49,7 @@ console.log(user); - const { password, ...newUser } = user; + const { data, password, ...newUser } = user; console.log(newUser); // User Object ohne sensbile Daten (password) diff --git a/02_advanced/unterricht/tag12/05_destructuring-in-paramerterliste.html b/02_advanced/unterricht/tag12/05_destructuring-in-paramerterliste.html index 2a6c8be..ab6d30a 100644 --- a/02_advanced/unterricht/tag12/05_destructuring-in-paramerterliste.html +++ b/02_advanced/unterricht/tag12/05_destructuring-in-paramerterliste.html @@ -16,6 +16,7 @@ 'use strict'; // Destructuring in der Parameterliste mit Defaultwert (Object) + // { DESTRUCTURING IN PARAMETERLISTE } = { NEUES DEFAULT OBJEKT} const foo = ({ a = 1, b = 2 } = { a: 3, b: 4 }) => `a: ${a}, b: ${b}`; const foo2 = (obj = {}) => { diff --git a/02_advanced/unterricht/tag12/10_rekursion-fibonacci.html b/02_advanced/unterricht/tag12/10_rekursion-fibonacci.html index c64c93f..9b906f0 100644 --- a/02_advanced/unterricht/tag12/10_rekursion-fibonacci.html +++ b/02_advanced/unterricht/tag12/10_rekursion-fibonacci.html @@ -29,12 +29,6 @@ return fibonacci(n - 1) + fibonacci(n - 2); }; - // 0 + 1 = 1 - // 1 + 1 = 2 - // 2 + 1 = 3 - // 3 + 2 = 5 - // 3 + 5 = 8 - // Test cases console.log(fibonacci(0)); // => 0 console.log(fibonacci(1)); // => 1 @@ -59,6 +53,41 @@ console.log(drawLine(5, '🤡')); // => '🤡🤡🤡🤡🤡🤡' console.log(drawLine(20, '🐣')); // => '🐣🐣🐣🐣🐣🐣🐣🐣🐣🐣🐣🐣🐣🐣🐣🐣🐣🐣🐣🐣' + + // ========================= + const fibonacciMitLog = (n, ebene = 0) => { + // Erzeugt Leerzeichen für die visuelle Einrückung in der Konsole + const einrückung = ' '.repeat(ebene); + + console.log(`${einrückung}▶️ Rufe fibonacci(${n}) auf`); + + // Base cases + if (n === 0) { + console.log(`${einrückung}↩️ Base Case: fibonacci(0) gibt 0 zurück`); + return 0; + } + + if (n === 1) { + console.log(`${einrückung}↩️ Base Case: fibonacci(1) gibt 1 zurück`); + return 1; + } + + // Rekursive Aufrufe + console.log(`${einrückung}⏳ Berechne links: fibonacci(${n - 1})`); + const links = fibonacciMitLog(n - 1, ebene + 1); + + console.log(`${einrückung}⏳ Berechne rechts: fibonacci(${n - 2})`); + const rechts = fibonacciMitLog(n - 2, ebene + 1); + + const ergebnis = links + rechts; + console.log(`${einrückung}✅ fibonacci(${n}) fertig! ${links} + ${rechts} = ${ergebnis}`); + + return ergebnis; + }; + + // Testlauf + console.log('--- START DER BERECHNUNG ---'); + fibonacciMitLog(4);