Skip to content

Commit 54106ba

Browse files
authored
Merge pull request lydiahallie#214 from jakeherp/patch-11
Questions 95 - 101 translated to German & typos fixed in English
2 parents 7e67178 + 99f0e03 commit 54106ba

File tree

2 files changed

+253
-10
lines changed

2 files changed

+253
-10
lines changed

de-DE/README.md

Lines changed: 250 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Die Antworten sind unterhalb der Fragen versteckt. Du kannst einfach darauf klic
99
### Alle verfügbaren Sprachen
1010
* [English](../en-EN/README.md)
1111
* [العربية](../ar-AR/README_AR.md)
12-
* [اللغة العامية - Egyptian Arabic](../ar-EG/README_ar-EG.md)
12+
* [اللغة العامية](../ar-EG/README_ar-EG.md)
1313
* [Bosanski](../bs-BS/README-bs_BS.md)
1414
* [Deutsch](../de-DE/README.md)
1515
* [Español](../es-ES/README-ES.md)
@@ -18,10 +18,10 @@ Die Antworten sind unterhalb der Fragen versteckt. Du kannst einfach darauf klic
1818
* [한국어](../ko-KR/README-ko_KR.md)
1919
* [Português Brasil](../pt-BR/README_pt_BR.md)
2020
* [Русский](../ru-RU/README_ru-RU.md)
21+
* [Türkçe](../tr-TR/README-tr_TR.md)
2122
* [Українська мова](../ua-UA/README-ua_UA.md)
2223
* [Tiếng Việt](../vi-VI/README-vi.md)
2324
* [中文版本](../zh-CN/README-zh_CN.md)
24-
* [Türkçe](../tr-TR/README-tr_TR.md)
2525

2626
---
2727

@@ -1324,7 +1324,7 @@ console.log(gen.next().value);
13241324
- A: `[0, 10], [10, 20]`
13251325
- B: `20, 20`
13261326
- C: `10, 20`
1327-
- D: `0, 10 and 10, 20`
1327+
- D: `0, 10 und 10, 20`
13281328

13291329
<details><summary><b>Antwort</b></summary>
13301330
<p>
@@ -2011,10 +2011,10 @@ Beim vierten Mal übergeben wir wieder eine `value`. `x.number` wurde zuvor in `
20112011
[1, 2, 3, 4].reduce((x, y) => console.log(x, y));
20122012
```
20132013

2014-
- A: `1` `2` and `3` `3` and `6` `4`
2015-
- B: `1` `2` and `2` `3` and `3` `4`
2016-
- C: `1` `undefined` and `2` `undefined` and `3` `undefined` and `4` `undefined`
2017-
- D: `1` `2` and `undefined` `3` and `undefined` `4`
2014+
- A: `1` `2` und `3` `3` und `6` `4`
2015+
- B: `1` `2` und `2` `3` und `3` `4`
2016+
- C: `1` `undefined` und `2` `undefined` und `3` `undefined` und `4` `undefined`
2017+
- D: `1` `2` und `undefined` `3` und `undefined` `4`
20182018

20192019
<details><summary><b>Antwort</b></summary>
20202020
<p>
@@ -2982,3 +2982,246 @@ getItems(["banana", "apple"], "pear", "orange")
29822982
Dieses Beispiel würde funktionieren und `[ 'banana', 'apple', 'orange', 'pear' ]` ausgeben.
29832983
</p>
29842984
</details>
2985+
2986+
---
2987+
2988+
###### <a name=20190817></a>95. Was ist der Output?
2989+
2990+
```javascript
2991+
function nums(a, b) {
2992+
if
2993+
(a > b)
2994+
console.log('a is bigger')
2995+
else
2996+
console.log('b is bigger')
2997+
return
2998+
a + b
2999+
}
3000+
3001+
console.log(nums(4, 2))
3002+
console.log(nums(1, 2))
3003+
```
3004+
3005+
- A: `a is bigger`, `6` und `b is bigger`, `3`
3006+
- B: `a is bigger`, `undefined` und `b is bigger`, `undefined`
3007+
- C: `undefined` und `undefined`
3008+
- D: `SyntaxError`
3009+
3010+
<details><summary><b>Antwort</b></summary>
3011+
<p>
3012+
3013+
#### Antwort: B
3014+
3015+
In JavaScript muss das Semikolon _nicht_ explizit gesetzt werden, allerdings setzt die JavaScript Engine Semikolons nach Statements. Diesen Vorgang nennt man **automatische Semikolonsetzung**. Ein Statement ist zum Beispiel eine Variable oder ein Keyword wie `throw`, `return`, `break`, usw.
3016+
3017+
In unserem Beispiel haben wir ein `return` Statement gefolgt von einem anderen Wert `a + b` auf der _nächsten Zeile_. Da es eine neue Zeile ist, weiß JavaScript nicht, dass das der Wert ist, den wir eigentlich ausgeben wollten. Stattdessen wird automatisch ein Semikolon nach `return` gesetzt, was man wiefolgt lesen kann:
3018+
3019+
```javascript
3020+
return;
3021+
a + b
3022+
```
3023+
3024+
Das bedeutet, dass `a + b` nie erreicht wird, da die Funktion auf der Zeile davor mit dem `return` Keyword endet. Wenn wie hier kein Wert ausgegeben wird, gibt die Funktion `undefined` aus.
3025+
Bedenke: Semikolons werden **nicht** automatisch nach `if/else` Statements gesetzt!
3026+
3027+
</p>
3028+
</details>
3029+
3030+
---
3031+
3032+
###### 96. Was ist der Output?
3033+
3034+
```javascript
3035+
class Person {
3036+
constructor() {
3037+
this.name = "Lydia"
3038+
}
3039+
}
3040+
3041+
Person = class AnotherPerson {
3042+
constructor() {
3043+
this.name = "Sarah"
3044+
}
3045+
}
3046+
3047+
const member = new Person()
3048+
console.log(member.name)
3049+
```
3050+
3051+
- A: `"Lydia"`
3052+
- B: `"Sarah"`
3053+
- C: `Error: cannot redeclare Person`
3054+
- D: `SyntaxError`
3055+
3056+
<details><summary><b>Antwort</b></summary>
3057+
<p>
3058+
3059+
#### Antwort: B
3060+
3061+
Wir können Klassen gleich anderen Klassen oder Funktions Konstruktoren setzen. In diesem Beispiel setzen wir `Person` gleich `AnotherPerson`. Der Name in diesem Konstruktor ist `Sarah`, sodass die name-Property der neuen `Person` Instanz `member` gleich `"Sarah"` ist.
3062+
3063+
</p>
3064+
</details>
3065+
3066+
---
3067+
3068+
###### 97. Was ist der Output?
3069+
3070+
```javascript
3071+
const info = {
3072+
[Symbol('a')]: 'b'
3073+
}
3074+
3075+
console.log(info)
3076+
console.log(Object.keys(info))
3077+
```
3078+
3079+
- A: `{Symbol('a'): 'b'}` und `["{Symbol('a')"]`
3080+
- B: `{}` und `[]`
3081+
- C: `{ a: "b" }` und `["a"]`
3082+
- D: `{Symbol('a'): 'b'}` und `[]`
3083+
3084+
<details><summary><b>Antwort</b></summary>
3085+
<p>
3086+
3087+
#### Antwort: D
3088+
3089+
Ein Symbol ist nicht _zählbar_. Die `Object.keys` Methode gibt alle zählbaren Key Properties eines Objekts aus. Das Symbol ist nicht sichtbar, sodass ein leeres Array ausgegeben wird. Wenn wir das gesamte Objekt loggen sind alle Properties sichtbar, auch nicht zählbare.
3090+
3091+
Das ist einer der vielen Vorteile eines Symbols: nebem einem einzigartigen Wert (welcher verhindert, dass versehentlich zwei Objekte gleiche Namen haben, zum Beispiel wenn wir mit verschiedenen Libraries arbeiten) können Properties von Objekten auf diese Art versteckt werden.
3092+
Bedenke: Man kann die Symbole dennoch mit der `Object.getOwnPropertySymbols()` Methode einsehen.
3093+
3094+
</p>
3095+
</details>
3096+
3097+
---
3098+
3099+
###### 98. Was ist der Output?
3100+
3101+
```javascript
3102+
const getList = ([x, ...y]) => [x, y]
3103+
const getUser = user => { name: user.name, age: user.age }
3104+
3105+
const list = [1, 2, 3, 4]
3106+
const user = { name: "Lydia", age: 21 }
3107+
3108+
console.log(getList(list))
3109+
console.log(getUser(user))
3110+
```
3111+
3112+
- A: `[1, [2, 3, 4]]` und `undefined`
3113+
- B: `[1, [2, 3, 4]]` und `{ name: "Lydia", age: 21 }`
3114+
- C: `[1, 2, 3, 4]` und `{ name: "Lydia", age: 21 }`
3115+
- D: `Error` und `{ name: "Lydia", age: 21 }`
3116+
3117+
<details><summary><b>Antwort</b></summary>
3118+
<p>
3119+
3120+
#### Antwort: A
3121+
3122+
Die `getList` Funktion bekommt ein Array als Argument zugewiesen. Zwischen den Klammern der `getList` Funktion wird das Array direkt destrukturiert. Man könnte das auch wiefolgt sehen:
3123+
3124+
`[x, ...y] = [1, 2, 3, 4]`
3125+
3126+
Mit dem Rest Parameter `...y` packen wir alle übrigen Argumente in ein Array. Die übrigen Argumente sind in dem Fall `2`, `3` und `4`. Der Wert von `y` ist ein Array mit den restlichen Parametern. Der Wert von `x` ist gleich `1` sodass `[1, [2, 3, 4]]` geloggt wird.
3127+
3128+
Die `getUser` Funktion bekommt ein Objekt zugewiesen. Bei Arrow Funktionen müssen wir keine geschweiften Klammern verwenden, wenn wir nur einen Wert ausgeben. Wenn wir aber ein _Objekt_ von einer Arrow Funktion ausgeben lassen möchten, so muss dieses zwischen Klammern stehen, ansonsten wird nichts ausgegeben. Die folgende Funktion hätte ein Objekt ausgegeben:
3129+
3130+
```const getUser = user => ({ name: user.name, age: user.age })```
3131+
3132+
Da kein Wert ausgegeben wird, gibt die Funktion `undefined` aus.
3133+
3134+
</p>
3135+
</details>
3136+
3137+
---
3138+
3139+
###### 99. Was ist der Output?
3140+
3141+
```javascript
3142+
const name = "Lydia"
3143+
3144+
console.log(name())
3145+
```
3146+
3147+
- A: `SyntaxError`
3148+
- B: `ReferenceError`
3149+
- C: `TypeError`
3150+
- D: `undefined`
3151+
3152+
<details><summary><b>Antwort</b></summary>
3153+
<p>
3154+
3155+
#### Antwort: C
3156+
3157+
Die Variable `name` beinhaltet einen String, welcher logischer Weise keine Funktion ist und daher nicht ausgeführt werden kann.
3158+
3159+
TypeErrors werden ausgeworfen, wenn ein Wert einen falschen Typ aufweist. JavaScript hat eine Funktion erwartet, da wir `name` ausführen. Da es aber ein String war bekommen wir den TypeError: name is not a function!
3160+
3161+
SyntaxErrors werden ausgeworfen, wenn wir etwas schreiben, was kein gültiger JavaScript Code ist, zum Beispiel wenn wir uns vertippen und anstatt `return` `retrun` schreiben.
3162+
3163+
ReferenceErrors werden ausgeworfen, wenn JavaScript eine Referenz zu einem Wert nicht finden kann.
3164+
3165+
</p>
3166+
</details>
3167+
3168+
---
3169+
3170+
###### 100. Was ist der Output?
3171+
3172+
```javascript
3173+
// 🎉✨ Das ist unsere 100. Frage! ✨🎉
3174+
3175+
const output = `${[] && 'Im'}possible!
3176+
You should${'' && `n't`} see a therapist after so much JavaScript lol`
3177+
```
3178+
3179+
- A: `possible! You should see a therapist after so much JavaScript lol`
3180+
- B: `Impossible! You should see a therapist after so much JavaScript lol`
3181+
- C: `possible! You shouldn't see a therapist after so much JavaScript lol`
3182+
- D: `Impossible! You shouldn't see a therapist after so much JavaScript lol`
3183+
3184+
<details><summary><b>Antwort</b></summary>
3185+
<p>
3186+
3187+
#### Antwort: B
3188+
3189+
`[]` ist ein "truthy" Wert. Mit dem `&&` Operator geben wir den rechten Wert aus, wenn der linke truthy ist. In diesem Fall ist `[]` truthy, wodurch `"Im'` ausgegeben wird.
3190+
3191+
`""` ein ein "falsy" Wert. Wenn der linke Wert falsy ist wird nichts ausgegeben. In diesem Fall wird `n't` _nicht_ ausgegeben.
3192+
3193+
</p>
3194+
</details>
3195+
3196+
---
3197+
3198+
###### 101. Was ist der Output?
3199+
3200+
```javascript
3201+
const one = (false || {} || null)
3202+
const two = (null || false || "")
3203+
const three = ([] || 0 || true)
3204+
3205+
console.log(one, two, three)
3206+
```
3207+
3208+
- A: `false` `null` `[]`
3209+
- B: `null` `""` `true`
3210+
- C: `{}` `""` `[]`
3211+
- D: `null` `null` `true`
3212+
3213+
<details><summary><b>Antwort</b></summary>
3214+
<p>
3215+
3216+
#### Antwort: C
3217+
3218+
Mit dem `||` Operator geben wir den ersten truthy Operand aus. Wenn alle Werte falsy sind wird der letzte Operand ausgegeben.
3219+
3220+
`(false || {} || null)`: das leere Objekt `{}` ist truthy. Das ist der erste und einzige truthy Wert und wird daher ausgegeben. `one` ist gleich `{}`.
3221+
3222+
`(null || false || "")`: alle Operanden sind falsy. Das bedeutet, dass der letzte Wert `""` ausgegeben wird. `two` ist gleich `""`.
3223+
3224+
`([] || 0 || "")`: das leere Array `[]` ist truthy. Das ist der erste truthy Wert, und wird daher ausgegeben. `three` ist gleich `[]`.
3225+
3226+
</p>
3227+
</details>

en-EN/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2718,7 +2718,7 @@ function getName(name) {
27182718

27192719
#### Answer: A
27202720

2721-
With `!!name`, we determine whether the value of `name` is truthy or falsey. If name is truthy, which we want to test for, `!name` returns `false`. `!false` (which is what `!!name` practically is) returns `true`.
2721+
With `!!name`, we determine whether the value of `name` is truthy or falsy. If name is truthy, which we want to test for, `!name` returns `false`. `!false` (which is what `!!name` practically is) returns `true`.
27222722

27232723
By setting `hasName` equal to `name`, you set `hasName` equal to whatever value you passed to the `getName` function, not the boolean value `true`.
27242724

@@ -3121,7 +3121,7 @@ The `getList` function receives an array as its argument. Between the parenthese
31213121

31223122
`[x, ...y] = [1, 2, 3, 4]`
31233123

3124-
With the rest parameter `...y`, we put all "remaining" arguments in an array. The remaining arguments are `2`, `3` and `4` in this case. The value of `y` is an array, containig all the rest parameters. The value of `x` is equal to `1` in this case, so when we log `[x, y]`, `[1, [2, 3, 4]]` gets logged.
3124+
With the rest parameter `...y`, we put all "remaining" arguments in an array. The remaining arguments are `2`, `3` and `4` in this case. The value of `y` is an array, containing all the rest parameters. The value of `x` is equal to `1` in this case, so when we log `[x, y]`, `[1, [2, 3, 4]]` gets logged.
31253125

31263126
The `getUser` function receives an object. With arrow functions, we don't _have_ to write curly brackets if we just return one value. However, if you want to return an _object_ from an arrow function, you have to write it between parentheses, otherwise no value gets returned! The following function would have returned an object:
31273127

@@ -3154,7 +3154,7 @@ console.log(name())
31543154

31553155
The variable `name` holds the value of a string, which is not a function, thus cannot invoke.
31563156

3157-
TypeErrors get thrown wehn a value is not of the expected type. JavaScript expected `name` to be a function since we're trying to invoke it. It was a string however, so a TypeError gets thrown: name is not a function!
3157+
TypeErrors get thrown when a value is not of the expected type. JavaScript expected `name` to be a function since we're trying to invoke it. It was a string however, so a TypeError gets thrown: name is not a function!
31583158

31593159
SyntaxErrors get thrown when you've written something that isn't valid JavaScript, for example when you've written the word `return` as `retrun`.
31603160
ReferenceErrors get thrown when JavaScript isn't able to find a reference to a value that you're trying to access.

0 commit comments

Comments
 (0)