68 lines
1.7 KiB
HTML
68 lines
1.7 KiB
HTML
<!doctype html>
|
|
<html lang="de">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
<title>Übung 18: 3D Array Zugriff</title>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/css/bootstrap.min.css" rel="stylesheet" />
|
|
</head>
|
|
<body>
|
|
<main>
|
|
<div class="container py-5">
|
|
<div class="alert alert-primary">
|
|
<h2>Übung 18: 3D Array Zugriff</h2>
|
|
<p>
|
|
Greife auf das zweite Produkt in der <strong>«Clothing»</strong>-Kategorie zu und ändere die Menge von
|
|
<strong>«Jeans»</strong> von 30 auf 25.
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
<script>
|
|
'use strict';
|
|
|
|
const inventory = [
|
|
[
|
|
// Category: Electronics
|
|
['Shelf 1', 'Laptop', 10],
|
|
['Shelf 2', 'Smartphone', 25],
|
|
],
|
|
[
|
|
// Category: Clothing
|
|
['Shelf 1', 'T-Shirts', 50],
|
|
['Shelf 2', 'Jeans', 30],
|
|
],
|
|
[
|
|
// Category: Groceries
|
|
['Shelf 1', 'Milk', 100],
|
|
['Shelf 2', 'Bread', 80],
|
|
],
|
|
[
|
|
// Category: Books
|
|
['Shelf 1', 'Novels', 40],
|
|
['Shelf 2', 'Non-fiction', 35],
|
|
],
|
|
];
|
|
|
|
// Your code here
|
|
inventory[1][1][2] -= 5;
|
|
inventory[1][1][2] = 25;
|
|
console.log(inventory);
|
|
/*
|
|
Expected outcome:
|
|
[
|
|
[ // Electronics
|
|
['Shelf 1', 'Laptop', 10],
|
|
['Shelf 2', 'Smartphone', 25],
|
|
],
|
|
[ // Clothing
|
|
['Shelf 1', 'T-Shirts', 50],
|
|
['Shelf 2', 'Jeans', 25], // Changed quantity
|
|
],
|
|
// ...
|
|
]
|
|
*/
|
|
</script>
|
|
</body>
|
|
</html>
|