80 lines
2.3 KiB
HTML
80 lines
2.3 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 47: Lückentext zu Higher-Order-Funktionen</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 47: Lückentext zu Higher-Order-Funktionen</h1>
|
|
<p>
|
|
Das ist garantiert der letzte Lückentext für diese Lektion. Ersetzen Sie wieder die Kommentare
|
|
<strong>/* ??? */</strong> durch den richtigen Code, um das angegebene Ergebnis zu erzielen.
|
|
</p>
|
|
</div>
|
|
</main>
|
|
<script>
|
|
'use strict';
|
|
|
|
let result;
|
|
let results;
|
|
let inputs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
|
let text = 'Hi this is a short text';
|
|
let names = ['Heribert', 'Friedlinde', 'Tusnelda', 'Oswine', 'Ladislaus'];
|
|
|
|
//odd numbers
|
|
//results = inputs
|
|
console.log(results); // => [ 1, 3, 5, 7, 9 ]
|
|
|
|
//sum
|
|
//result = inputs
|
|
console.log(result); // => 55
|
|
|
|
//product
|
|
//result = inputs
|
|
console.log(result); // => 3628800
|
|
|
|
//longest word length
|
|
result = text.split(' '); //=> ['Hi', 'this', 'is', 'a', 'short', 'text'];
|
|
//
|
|
|
|
console.log(result); // => 5
|
|
|
|
//longest word
|
|
result = text.split(' '); //=> ['Hi', 'this', 'is', 'a', 'short', 'text'];
|
|
//
|
|
|
|
console.log(result); // =>'short'
|
|
|
|
//avg word length =========================
|
|
|
|
// result =
|
|
console.log(result); // => 3
|
|
|
|
//sort by 3rd letter
|
|
// ['Heribert', 'Friedlinde', 'Tusnelda', 'Oswine', 'Ladislaus'];
|
|
|
|
const names2 = [...names];
|
|
// results =
|
|
console.log(results); // => [ 'Ladislaus', 'Friedlinde', 'Heribert', 'Tusnelda', 'Oswine' ]
|
|
|
|
// Are there names with more than 8 letters?
|
|
// ['Heribert', 'Friedlinde', 'Tusnelda', 'Oswine', 'Ladislaus'];
|
|
|
|
// result = names
|
|
|
|
// Has every name at least 8 letters?
|
|
// result = names
|
|
console.log(result); // false
|
|
|
|
// What is the lowest value from the inputs?
|
|
// [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
|
// result = inputs
|
|
console.log(result);
|
|
</script>
|
|
</body>
|
|
</html>
|