From 2f8cd0b61e06ef04ed3aecf29289b31380b12214 Mon Sep 17 00:00:00 2001 From: Philippe Torrel Date: Mon, 17 Aug 2026 13:26:23 +0200 Subject: [PATCH] --- .../01_inversion/01_verschachtelte-ifs.html | 65 +++++++++++++ .../02_optimierung-durch-inversion.html | 68 ++++++++++++++ .../02_extraction/01_verschachtelte-ifs.html | 61 ++++++++++++ .../02_optimierung-durch-extraction.html | 79 ++++++++++++++++ .../tag46/03_dry/01_calc-rectangle.html | 41 ++++++++ .../03_dry/02_optimierung-durch-dry.html | 87 +++++++++++++++++ .../tag46/03_dry/03_range-helper.js | 93 +++++++++++++++++++ .../tag46/04_error-types/01_syntax-error.html | 63 +++++++++++++ .../04_error-types/02_reference-error.html | 50 ++++++++++ .../tag46/04_error-types/03_type-error.html | 39 ++++++++ 10 files changed, 646 insertions(+) create mode 100644 06_js-debug/unterricht/tag46/01_inversion/01_verschachtelte-ifs.html create mode 100644 06_js-debug/unterricht/tag46/01_inversion/02_optimierung-durch-inversion.html create mode 100644 06_js-debug/unterricht/tag46/02_extraction/01_verschachtelte-ifs.html create mode 100644 06_js-debug/unterricht/tag46/02_extraction/02_optimierung-durch-extraction.html create mode 100644 06_js-debug/unterricht/tag46/03_dry/01_calc-rectangle.html create mode 100644 06_js-debug/unterricht/tag46/03_dry/02_optimierung-durch-dry.html create mode 100644 06_js-debug/unterricht/tag46/03_dry/03_range-helper.js create mode 100644 06_js-debug/unterricht/tag46/04_error-types/01_syntax-error.html create mode 100644 06_js-debug/unterricht/tag46/04_error-types/02_reference-error.html create mode 100644 06_js-debug/unterricht/tag46/04_error-types/03_type-error.html diff --git a/06_js-debug/unterricht/tag46/01_inversion/01_verschachtelte-ifs.html b/06_js-debug/unterricht/tag46/01_inversion/01_verschachtelte-ifs.html new file mode 100644 index 0000000..a70e59a --- /dev/null +++ b/06_js-debug/unterricht/tag46/01_inversion/01_verschachtelte-ifs.html @@ -0,0 +1,65 @@ + + + + + + Nesting if-statements + + + +
+
+

Nesting if-statements

+
+
+ + + diff --git a/06_js-debug/unterricht/tag46/01_inversion/02_optimierung-durch-inversion.html b/06_js-debug/unterricht/tag46/01_inversion/02_optimierung-durch-inversion.html new file mode 100644 index 0000000..2d113e1 --- /dev/null +++ b/06_js-debug/unterricht/tag46/01_inversion/02_optimierung-durch-inversion.html @@ -0,0 +1,68 @@ + + + + + + Nesting if-statements vermeiden über inversion + + + +
+
+

Nesting if-statements vermeiden über inversion

+
+
+ + + diff --git a/06_js-debug/unterricht/tag46/02_extraction/01_verschachtelte-ifs.html b/06_js-debug/unterricht/tag46/02_extraction/01_verschachtelte-ifs.html new file mode 100644 index 0000000..2ad1d7d --- /dev/null +++ b/06_js-debug/unterricht/tag46/02_extraction/01_verschachtelte-ifs.html @@ -0,0 +1,61 @@ + + + + + + Nested if-statements + + + +
+
+

Nested if-statements

+
+
+ + + diff --git a/06_js-debug/unterricht/tag46/02_extraction/02_optimierung-durch-extraction.html b/06_js-debug/unterricht/tag46/02_extraction/02_optimierung-durch-extraction.html new file mode 100644 index 0000000..cb928ee --- /dev/null +++ b/06_js-debug/unterricht/tag46/02_extraction/02_optimierung-durch-extraction.html @@ -0,0 +1,79 @@ + + + + + + Extraction + + + +
+
+

Extraction

+
+
+ + + diff --git a/06_js-debug/unterricht/tag46/03_dry/01_calc-rectangle.html b/06_js-debug/unterricht/tag46/03_dry/01_calc-rectangle.html new file mode 100644 index 0000000..c6c6879 --- /dev/null +++ b/06_js-debug/unterricht/tag46/03_dry/01_calc-rectangle.html @@ -0,0 +1,41 @@ + + + + + + DRY - Don't Repeat Yourself + + + +
+
+

DRY - Don't Repeat Yourself

+
+
+ + + diff --git a/06_js-debug/unterricht/tag46/03_dry/02_optimierung-durch-dry.html b/06_js-debug/unterricht/tag46/03_dry/02_optimierung-durch-dry.html new file mode 100644 index 0000000..5d654a5 --- /dev/null +++ b/06_js-debug/unterricht/tag46/03_dry/02_optimierung-durch-dry.html @@ -0,0 +1,87 @@ + + + + + + DRY - Don't Repeat Yourself - Regel angewandt + + + + +
+
+

DRY - Don't Repeat Yourself - Regel angewandt

+
+
+
+ + + diff --git a/06_js-debug/unterricht/tag46/03_dry/03_range-helper.js b/06_js-debug/unterricht/tag46/03_dry/03_range-helper.js new file mode 100644 index 0000000..f1565fc --- /dev/null +++ b/06_js-debug/unterricht/tag46/03_dry/03_range-helper.js @@ -0,0 +1,93 @@ +// Helper DOM Selektion mit $ & $$ +const $ = (qs) => document.querySelector(qs); +const $$ = (qs) => Array.from(document.querySelectorAll(qs)); + +// NodeList.prototype.__proto__ = Array.prototype; +// NodeList erhält alle Methode vom Array. NodeList wird zum Array (ACHTUNG: Veränderung vom ECMAScript Standard) + +Node.prototype.on = function (name, fn) { + this.addEventListener(name, fn); + return this; +}; + +// // anstatt +// document.querySelector('button').addEventListener('click', (event) => { }); +// // wird zu: +// document.querySelector('button').on('click', (event) => { }); + +Array.prototype.on = Array.prototype.addEventListener = function (name, fn) { + this.forEach((elem) => elem.on(name, fn)); + return this; +}; + +// anstatt +// Array.from(document.querySelectorAll('.menu-main li a')).forEach((elem) => +// elem.addEventListener('click', (event) => { +// console.log(event); +// }) +// ); +// // wird zu +// Array.from(document.querySelectorAll('.menu-main li a')).on( +// 'click', +// (event) => { +// console.log(event); +// } +// ); + +// helper +const $on = (el, ev, fn) => { + Array.isArray(el) ? el.forEach((ae) => $on(ae, ev, fn)) : el.addEventListener(ev, fn); + return el; +}; + +// times - funktion +function times(n, fn) { + const result = Array(n); + for (let i = 0; i < n; i++) { + result[i] = fn(i); + } + return result; +} +// oder von lodash +function baseTimes(n, iteratee) { + var index = -1, + result = Array(n); + + while (++index < n) { + result[index] = iteratee(index); + } + return result; +} + +// times(3, () => 'ho'); // => ['ho','ho','ho'] + +/* + * range(zahl bis wohin array befüllt werden soll) : array + * - array von 0 bis + parameterzahl (nicht inklusive) + * + * range(anfangswert, endwert) : array + * - array von anfangswert bis endwert (nicht inklusive) + * + * range(nfangswert, endwert, übersprungswert) : : array + * - array von anfangswert bis endwert (nicht inklusive), zwischenwerte durch übersprungswert entfallen +*/ +function rangeFromStartToEnd(start, end, step = 1) { + const length = Math.max(Math.ceil((end - start) / step), 0); + const result = new Array(length); + const sign = step / Math.abs(step); + + let index = 0; + for (let value = start; value * sign < end * sign; value += step) { + result[index++] = value; + } + return result; +} + +function range(startOrEnd, end, step) { + if (end) { + return rangeFromStartToEnd(startOrEnd, end, step); + } else { + return rangeFromStartToEnd(0, startOrEnd); + } +} diff --git a/06_js-debug/unterricht/tag46/04_error-types/01_syntax-error.html b/06_js-debug/unterricht/tag46/04_error-types/01_syntax-error.html new file mode 100644 index 0000000..559b38a --- /dev/null +++ b/06_js-debug/unterricht/tag46/04_error-types/01_syntax-error.html @@ -0,0 +1,63 @@ + + + + + + Syntax Error + + + +
+
+

Syntax Error

+
+
+ + + diff --git a/06_js-debug/unterricht/tag46/04_error-types/02_reference-error.html b/06_js-debug/unterricht/tag46/04_error-types/02_reference-error.html new file mode 100644 index 0000000..1b81733 --- /dev/null +++ b/06_js-debug/unterricht/tag46/04_error-types/02_reference-error.html @@ -0,0 +1,50 @@ + + + + + + Reference Error + + + +
+
+

Reference Error

+
+
+ + + diff --git a/06_js-debug/unterricht/tag46/04_error-types/03_type-error.html b/06_js-debug/unterricht/tag46/04_error-types/03_type-error.html new file mode 100644 index 0000000..b95c4f8 --- /dev/null +++ b/06_js-debug/unterricht/tag46/04_error-types/03_type-error.html @@ -0,0 +1,39 @@ + + + + + + Type Error + + + +
+
+

Type Error

+
+
+ + +