diff --git a/01_grundlagen/uebungen/#u36_kekse-array.html b/01_grundlagen/uebungen/u36_kekse-array.html similarity index 88% rename from 01_grundlagen/uebungen/#u36_kekse-array.html rename to 01_grundlagen/uebungen/u36_kekse-array.html index 5fa42e2..63c2ee7 100644 --- a/01_grundlagen/uebungen/#u36_kekse-array.html +++ b/01_grundlagen/uebungen/u36_kekse-array.html @@ -83,6 +83,24 @@ '1/2 cup sugar', '1 tsp baking powder', ]; + + // 36.1 + receipeAr.push('1 tsp flour'); + + // 36.2 + receipeAr.unshift('1 cup rolled oats'); + // 36.2 + receipeAr.splice(1, 1, '1/3 cup butter'); + receipeAr[1] = '1/3 cup butter'; + + // 36.3 + const receipeStr = receipeAr.join('\n'); + + console.log(`Oat-Cookie Receipe:\n\n${receipeStr}\n\n${introduction}`); + + outputEl.innerHTML = `

${introduction}

+

Oat-Cookie Receipe:

+
  1. ${receipeAr.join('
  2. ')}
`; diff --git a/01_grundlagen/uebungen/#u37-bus-stations.html b/01_grundlagen/uebungen/u37-bus-stations.html similarity index 72% rename from 01_grundlagen/uebungen/#u37-bus-stations.html rename to 01_grundlagen/uebungen/u37-bus-stations.html index 85a9bae..2f3368a 100644 --- a/01_grundlagen/uebungen/#u37-bus-stations.html +++ b/01_grundlagen/uebungen/u37-bus-stations.html @@ -1,4 +1,4 @@ - + @@ -76,6 +76,28 @@ const LINE_W = [ '39 Av', 'Queensboro Plaza', ]; + + // Finde die Position der gewünschten Zielhaltestelle Broadway heraus. + console.log(LINE_W.indexOf('Broadway')); //=> 3 + + // Entferne alle Haltestellen nach Broadway aus dem Array. + const lineCopy = [...LINE_W]; + console.log(lineCopy.splice(lineCopy.indexOf('Broadway') + 1, lineCopy.length - lineCopy.indexOf('Broadway'))); + console.log(lineCopy); + + const calcStartStopPlan = (start, destination, withStart = false) => { + const posStart = withStart ? LINE_W.indexOf(start) : LINE_W.indexOf(start) + 1; + const posEnd = LINE_W.indexOf(destination); + // Guard + if (posStart === -1 || posEnd === -1) return []; + + return LINE_W.slice(posStart, posEnd + 1); + }; + + const schedule = calcStartStopPlan('Astoria-Ditmars Blvd', 'Broadway').join(' --- '); + // const schedule = calcStartStopPlan('Astoria-Ditmars Blvd', 'Broadway', true).join(' --- '); + + outputEl.textContent = schedule; diff --git a/01_grundlagen/uebungen/#u38_alte-listen.html b/01_grundlagen/uebungen/u38_alte-listen.html similarity index 96% rename from 01_grundlagen/uebungen/#u38_alte-listen.html rename to 01_grundlagen/uebungen/u38_alte-listen.html index 47a8a08..a98516a 100644 --- a/01_grundlagen/uebungen/#u38_alte-listen.html +++ b/01_grundlagen/uebungen/u38_alte-listen.html @@ -34,10 +34,12 @@ '3Doodler 3D Printing Pen, Game of Thrones Wax Seal Coasters, 10th Doctor Sonic Screwdriver Exclusive Programmable TV Remote, Electronic Butterfly in a Jar, Aquafarm: Aquaponics Fish Garden, Cassette Adapter Bluetooth, Marvel Comics Lightweight Infinity Scarf, Ollie - The App Controlled Robot, Sound Splash Bluetooth Waterproof Shower Speaker, PowerCube, Backpack of Holding, Retro Duo Portable NES/SNES Game System, Universal Gadget Wrist Charger, USB Squirming Tentacle, USB Fishquarium, Space Bar Keyboard Organizer & USB Hub Pop, USB Pet Rock, Powerstation 5- E. Maximus Chargus, Dual Heated Travel Mug, Crosley Collegiate Portable USB Turntable, Meh Hoodie, Magnetic Accelerator Cannon, 8-Bit Heat-Change Mug'; const handleCsv = (csvStr) => { - //return csvStr.split(', ').sort(); + // return csvStr.split(',').sort(); return csvStr.split(/\s*,\s*/).sort(); }; + console.log(handleCsv(productList)); + outputEl.innerHTML = ``; diff --git a/01_grundlagen/unterricht/tag08/05_array-object.html b/01_grundlagen/unterricht/tag08/05_array-object.html index 035a5b0..08951fa 100644 --- a/01_grundlagen/unterricht/tag08/05_array-object.html +++ b/01_grundlagen/unterricht/tag08/05_array-object.html @@ -62,7 +62,7 @@ // Sonderfall: Array über Konstruktor-Objekt erstellen const lottoNumbers = new Array(6); //=> [empty,empty,empty,empty,empty,empty ] - lottoNumbers.fill(); //=> [0,0,0,0,0,0] + lottoNumbers.fill(0); //=> [0,0,0,0,0,0] // Array -- Eigenschaft ar.length @@ -74,6 +74,12 @@ console.log(Array.isArray([1, 2, 3])); //=> true console.log(Array.isArray(names)); //=> true console.log(Array.isArray(123)); //=> false + + // console.log([1, 2, 3] === [1, 2, 3]); //=> false + // console.log([] === []); //=> false + + console.log([1, 2, 3].toString() === [1, 2, 3].toString()); //=> true + console.log([1, 2, 3].toString() === [1, '2', 3].toString()); //=> true diff --git a/01_grundlagen/unterricht/tag08/10_ar-splice.html b/01_grundlagen/unterricht/tag08/10_ar-splice.html index 343a458..ecc7bb5 100644 --- a/01_grundlagen/unterricht/tag08/10_ar-splice.html +++ b/01_grundlagen/unterricht/tag08/10_ar-splice.html @@ -66,7 +66,11 @@ // ar.splice(startIndex, deleteCount, ...addValueN) cuttedNames = namesCopy.splice(1, 2, 'Jane', 'John'); + // namesCopy[1] = 'Jane' + // namesCopy[2] = 'John' + console.log(cuttedNames); //=> ['Andreas', 'Adel']; + console.log(namesCopy); //=> ['Ersin', 'Jane', 'John', 'Kahleel', 'Philippe'] // Mehrere Werte gezielt am Ende hinzufügen ===================== diff --git a/01_grundlagen/unterricht/tag09/01_str-split.html b/01_grundlagen/unterricht/tag09/01_str-split.html new file mode 100644 index 0000000..2ed8726 --- /dev/null +++ b/01_grundlagen/unterricht/tag09/01_str-split.html @@ -0,0 +1,64 @@ + + + + + + String.split() + + + +
+
+

String - str.split()

+

+ + str.split() + + - Die split() Methode teilt ein String Objekt in ein Array von Strings auf, indem der String + in Teilstrings zerteilt wird, wobei ein angegebenes Trennzeichen verwendet wird, um zu bestimmen, wo die + Aufteilung erfolgen soll. +

+ +
+
+
+ + + diff --git a/01_grundlagen/unterricht/tag09/02_ar-reverse.html b/01_grundlagen/unterricht/tag09/02_ar-reverse.html new file mode 100644 index 0000000..fd2fe6b --- /dev/null +++ b/01_grundlagen/unterricht/tag09/02_ar-reverse.html @@ -0,0 +1,51 @@ + + + + + + Array.reverse() + + + +
+
+

Array - ar.reverse()

+

+ + ar.reverse() + + - Die Methode von Array Instanzen kehrt ein Array in place um und gibt die Referenz auf dasselbe + Array zurück, wobei das erste Array-Element nun zum letzten und das letzte Array-Element zum ersten wird. Mit + anderen Worten, die Reihenfolge der Elemente im Array wird in die entgegengesetzte Richtung gedreht. +

+
+
+
+ + +