This commit is contained in:
Philippe Torrel
2026-06-25 10:35:17 +02:00
parent ccff1b73d6
commit db2ec6838a
7 changed files with 170 additions and 3 deletions

View File

@@ -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 = `<p>${introduction}</p>
<h3>Oat-Cookie Receipe:</h3>
<ol><li>${receipeAr.join('</li><li>')}</li></ol>`;
</script>
</body>
</html>

View File

@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="de">
<head>
<meta charset="UTF-8" />
@@ -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;
</script>
</body>
</html>

View File

@@ -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 = `<ul><li>${handleCsv(productList).join('</li><li>')}</li></ul>`;
</script>
</body>