You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+13-12
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
I post daily multiple choice JavaScript questions on my [Instagram](https://www.instagram.com/theavocoder), which I'll also post here!
4
4
5
-
From basic to advanced: test how well you know JavaScript, refresh your knowledge a bit, or prepare for your coding interview! :muscle::rocket:
5
+
From basic to advanced: test how well you know JavaScript, refresh your knowledge a bit, or prepare for your coding interview! :muscle::rocket: I update this repo weekly with new questions.
6
6
7
7
The answers are in the collapsed sections below the questions, simply click on them to expand it. Good luck :heart:
8
8
@@ -242,6 +242,7 @@ However, when we use the `===` operator, both value _and_ type should be the sam
242
242
classChameleon {
243
243
staticcolorChange(newColor) {
244
244
this.newColor= newColor;
245
+
returnthis.newColor;
245
246
}
246
247
247
248
constructor({ newColor ="green" } = {}) {
@@ -400,7 +401,7 @@ We said that `this.firstName` equals `"Sarah"` and `this.lastName` equals `"Smit
400
401
401
402
---
402
403
403
-
###### 12. What are the three phases of event propagation?
404
+
###### 13. What are the three phases of event propagation?
404
405
405
406
- A: Target > Capturing > Bubbling
406
407
- B: Bubbling > Target > Capturing
@@ -421,7 +422,7 @@ During the **capturing** phase, the event goes through the ancestor elements dow
421
422
422
423
---
423
424
424
-
###### 13. All objects have prototypes.
425
+
###### 14. All object have prototypes.
425
426
426
427
- A: true
427
428
- B: false
@@ -438,7 +439,7 @@ All objects have prototypes, except for the **base object**. The base object has
438
439
439
440
---
440
441
441
-
###### 14. What's the output?
442
+
###### 15. What's the output?
442
443
443
444
```javascript
444
445
functionsum(a, b) {
@@ -458,7 +459,7 @@ sum(1, "2");
458
459
459
460
#### Answer: C
460
461
461
-
JavaScript is a **dynamically typed language**: we don't specify what types certain variables are. Values can automatically be converted into another type without you knowing, which is called _implicit type coercion_. **Coercion** is converting from one type into another.
462
+
JavaScript is a **dynamimcally typed language**: we don't specify what types certain variables are. Values can automatically be converted into another type without you knowing, which is called _implicit type coercion_. **Coercion** is converting from one type into another.
462
463
463
464
In this example, JavaScript converts the number `1` into a string, in order for the function to make sense and return a value. During the addition of a numeric type (`1`) and a string type (`'2'`), the number is treated as a string. We can concatenate strings like `"Hello" + "World"`, so what's happening here is `"1" + "2"` which returns `"12"`.
464
465
@@ -467,7 +468,7 @@ In this example, JavaScript converts the number `1` into a string, in order for
467
468
468
469
---
469
470
470
-
###### 15. What's the output?
471
+
###### 16. What's the output?
471
472
472
473
```javascript
473
474
let number =0;
@@ -503,7 +504,7 @@ This returns `0 2 2`.
503
504
504
505
---
505
506
506
-
###### 16. What's the output?
507
+
###### 17. What's the output?
507
508
508
509
```javascript
509
510
functiongetPersonInfo(one, two, three) {
@@ -518,9 +519,9 @@ const age = 21;
518
519
getPersonInfo`${person} is ${age} years old`;
519
520
```
520
521
521
-
- A: `Lydia``21``["", "is", "years old"]`
522
-
- B: `["", "is", "years old"]``Lydia``21`
523
-
- C: `Lydia``["", "is", "years old"]``21`
522
+
- A: `"Lydia"``21``["", " is ", "years old"]`
523
+
- B: `["", " is ", "years old"]``"Lydia"``21`
524
+
- C: `"Lydia"``["", " is ", "years old"]``21`
524
525
525
526
<details><summary><b>Answer</b></summary>
526
527
<p>
@@ -534,7 +535,7 @@ If you use tagged template literals, the value of the first argument is always a
534
535
535
536
---
536
537
537
-
###### 17. What's the output?
538
+
###### 18. What's the output?
538
539
539
540
```javascript
540
541
functioncheckAge(data) {
@@ -570,7 +571,7 @@ This is why both `{ age: 18 } === { age: 18 }` and `{ age: 18 } == { age: 18 }`
0 commit comments