This commit is contained in:
40
01_grundlagen/uebungen/u40_map-lueckentext.html
Normal file
40
01_grundlagen/uebungen/u40_map-lueckentext.html
Normal file
@@ -0,0 +1,40 @@
|
||||
<!doctype html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Übung 40: Lückentext zu map</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">
|
||||
<h1>Übung 40: Lückentext zu map</h1>
|
||||
<p>
|
||||
Wir wollen Sie bei der ersten Übung zu <strong>map</strong> nicht gleich ins kalte Wasser werfen. Stattdessen
|
||||
haben wir einen kleinen Lückentext vorbereitet, bei dem Sie nur wenig ergänzen müssen. Ersetzen Sie die
|
||||
Kommentare <code>/* ??? */</code> durch den richtigen Code, um das angegebene Ergebnis zu erzielen.
|
||||
</p>
|
||||
</div>
|
||||
</main>
|
||||
<script>
|
||||
'use strict';
|
||||
|
||||
let results;
|
||||
let inputs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||
|
||||
//double
|
||||
results = inputs.map((num) => num * 2);
|
||||
console.log(results); // => [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
|
||||
|
||||
//squares
|
||||
results = inputs.map((num) => num * num);
|
||||
results = inputs.map((num) => num ** 2);
|
||||
results = inputs.map((num) => Math.pos(num, 2));
|
||||
// => [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
|
||||
console.log(results);
|
||||
|
||||
//
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user