Skip to content

Commit 629ea22

Browse files
authored
Merge pull request #194 from behrends/Strings
Strings
2 parents 3421d40 + cf81e6f commit 629ea22

File tree

8 files changed

+215
-219
lines changed

8 files changed

+215
-219
lines changed

1-js/05-data-types/03-string/1-ucfirst/solution.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
We can't "replace" the first character, because strings in JavaScript are immutable.
1+
Wir können das erste Zeichen nicht "ersetzen", da Strings in JavaScript unveränderlich sind.
22

3-
But we can make a new string based on the existing one, with the uppercased first character:
3+
Wir können jedoch einen neuen String basierend auf dem bestehenden erstellen, mit einem großgeschriebenen ersten Buchstaben:
44

55
```js
66
let newStr = str[0].toUpperCase() + str.slice(1);
77
```
88

9-
There's a small problem though. If `str` is empty, then `str[0]` is `undefined`, and as `undefined` doesn't have the `toUpperCase()` method, we'll get an error.
9+
Es gibt jedoch ein kleines Problem. Wenn `str` leer ist, dann ist `str[0]` `undefined`, und da `undefined` nicht die Methode `toUpperCase()` besitzt, erhalten wir einen Fehler.
1010

11-
The easiest way out is to add a test for an empty string, like this:
11+
Der einfachste Ausweg ist, eine Überprüfung auf einen leeren String hinzuzufügen, so wie hier:
1212

1313
```js run demo
1414
function ucFirst(str) {

1-js/05-data-types/03-string/1-ucfirst/task.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ importance: 5
22

33
---
44

5-
# Uppercase the first character
5+
# Den ersten Buchstaben großschreiben
66

7-
Write a function `ucFirst(str)` that returns the string `str` with the uppercased first character, for instance:
7+
Schreibe eine Funktion `ucFirst(str)`, die den String `str` zurückgibt, wobei der erste Buchstabe großgeschrieben ist, beispielsweise:
88

99
```js
1010
ucFirst("john") == "John";
1111
```
12-

1-js/05-data-types/03-string/2-check-spam/solution.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
To make the search case-insensitive, let's bring the string to lower case and then search:
1+
Um die Suche unabhängig von Groß- und Kleinschreibung zu gestalten, bringen wir den String in Kleinbuchstaben und suchen dann:
22

33
```js run demo
44
function checkSpam(str) {
@@ -11,4 +11,3 @@ alert( checkSpam('buy ViAgRA now') );
1111
alert( checkSpam('free xxxxx') );
1212
alert( checkSpam("innocent rabbit") );
1313
```
14-

1-js/05-data-types/03-string/2-check-spam/task.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@ importance: 5
22

33
---
44

5-
# Check for spam
5+
# Überprüfung auf Spam
66

7-
Write a function `checkSpam(str)` that returns `true` if `str` contains 'viagra' or 'XXX', otherwise `false`.
7+
Schreibe eine Funktion `checkSpam(str)`, die `true` zurückgibt, wenn `str` 'viagra' oder 'XXX' enthält, ansonsten `false`.
88

9-
The function must be case-insensitive:
9+
Die Funktion muss Groß- und Kleinschreibung ignorieren:
1010

1111
```js
1212
checkSpam('buy ViAgRA now') == true
1313
checkSpam('free xxxxx') == true
1414
checkSpam("innocent rabbit") == false
1515
```
16-

1-js/05-data-types/03-string/3-truncate/solution.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
The maximal length must be `maxlength`, so we need to cut it a little shorter, to give space for the ellipsis.
1+
Die maximale Länge muss `maxlength` sein, daher müssen wir den Text ein wenig kürzen, um Platz für die Auslassungspunkte zu schaffen.
22

3-
Note that there is actually a single Unicode character for an ellipsis. That's not three dots.
3+
Beachte, dass es tatsächlich ein einzelnes Unicode-Zeichen für eine Auslassung gibt. Das sind nicht drei Punkte.
44

55
```js run demo
66
function truncate(str, maxlength) {

1-js/05-data-types/03-string/3-truncate/task.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ importance: 5
22

33
---
44

5-
# Truncate the text
5+
# Kürze den Text
66

7-
Create a function `truncate(str, maxlength)` that checks the length of the `str` and, if it exceeds `maxlength` -- replaces the end of `str` with the ellipsis character `"…"`, to make its length equal to `maxlength`.
7+
Erstelle eine Funktion `truncate(str, maxlength)`, die die Länge des Strings `str` überprüft und - falls diese `maxlength` übersteigt - das Ende von `str` mit dem Auslassungszeichen `"…"` ersetzt, um seine Länge an `maxlength` anzupassen.
88

9-
The result of the function should be the truncated (if needed) string.
9+
Das Ergebnis der Funktion sollte der gekürzte (falls nötig) String sein.
1010

11-
For instance:
11+
Zum Beispiel:
1212

1313
```js
1414
truncate("What I'd like to tell on this topic is:", 20) = "What I'd like to te…"

1-js/05-data-types/03-string/4-extract-currency/task.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@ importance: 4
22

33
---
44

5-
# Extract the money
5+
# Extrahiere den Geldbetrag
66

7-
We have a cost in the form `"$120"`. That is: the dollar sign goes first, and then the number.
7+
Wir haben Kosten in der Form `"$120"`. Das heißt: das Dollarzeichen steht zuerst, und dann die Zahl.
88

9-
Create a function `extractCurrencyValue(str)` that would extract the numeric value from such string and return it.
9+
Erstelle eine Funktion `extractCurrencyValue(str)`, die den numerischen Wert aus einem solchen String extrahiert und ihn zurückgibt.
1010

11-
The example:
11+
Das Beispiel:
1212

1313
```js
1414
alert( extractCurrencyValue('$120') === 120 ); // true
1515
```
16-

0 commit comments

Comments
 (0)