added uebungen 1 - 10

This commit is contained in:
Philippe Torrel
2026-06-30 15:02:55 +02:00
parent 41efb8a5ab
commit f642829cb1
11 changed files with 386 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Übung 9: Tiefste Ebene eines verschachtelten Arrays finden</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-warning">
<h2>Übung 9 (advanced): Tiefste Ebene eines verschachtelten Arrays finden</h2>
<p>
Schreibe eine rekursive Funktion in JavaScript, die die tiefste Ebene eines verschachtelten Arrays bestimmt.
Die Funktion soll die maximale Verschachtelungstiefe des Arrays zurückgeben.
</p>
</div>
</div>
</main>
<script>
'use strict';
const findDeepestLevel = (arr, currentLevel = 1) => {};
// Test cases
console.log(findDeepestLevel([1, [2, [3, [4]], 5]])); // => 4
console.log(findDeepestLevel([1, 2, 3, 4, 5])); // => 1
console.log(findDeepestLevel([])); // => 1
console.log(findDeepestLevel([1, [2], [3, [4, [5]]]])); // => 4
console.log(findDeepestLevel([1, [2, [3]], [4, [5, [6]]]])); // => 4
</script>
</body>
</html>