Skip to content

Commit d33f504

Browse files
authored
chore(curriculum): adding questions for maps and sets lecture (freeCodeCamp#57319)
1 parent 24d45ae commit d33f504

File tree

2 files changed

+186
-10
lines changed

2 files changed

+186
-10
lines changed

curriculum/challenges/english/25-front-end-development/lecture-working-with-maps-and-sets/6733ab269b378bf724c9ac71.md

Lines changed: 93 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,108 @@ Watch the video lecture and answer the questions below.
1414

1515
## --text--
1616

17-
What Is the Map Object, and How Does It Differ from WeakMaps? question?
17+
How does a `Set` differ from a `WeakSet` when it comes to the data they both support?
1818

1919
## --answers--
2020

21-
Answer 1
21+
A `Set` allows weakly held object references, while a `WeakSet` supports both objects and primitives.
22+
23+
### --feedback--
24+
25+
Remember that a `Set` can hold a variety of data types.
26+
27+
---
28+
29+
A `Set` stores any type, including primitives, while a `WeakSet` allows only weakly held object references.
2230

2331
---
2432

25-
Answer 2
33+
A `Set` has fewer features than a `WeakSet`.
34+
35+
### --feedback--
36+
37+
Remember that a `Set` can hold a variety of data types.
2638

2739
---
2840

29-
Answer 3
41+
A `Set` is exclusively for objects, while a `WeakSet` is for numbers.
42+
43+
### --feedback--
44+
45+
Remember that a `Set` can hold a variety of data types.
46+
47+
## --video-solution--
48+
49+
2
50+
51+
## --text--
52+
53+
How do you create a `Set` or a `WeakSet` in JavaScript?
54+
55+
## --answers--
56+
57+
By calling `Set()` or `WeakSet()` without the `new` keyword
58+
59+
### --feedback--
60+
61+
Think about what keyword needs to be included to create a `Set` or `WeakSet`.
62+
63+
---
64+
65+
By using object literals `{}`
66+
67+
### --feedback--
68+
69+
Think about what keyword needs to be included to create a `Set` or `WeakSet`.
70+
71+
---
72+
73+
By using array literals `[]`
74+
75+
### --feedback--
76+
77+
Think about what keyword needs to be included to create a `Set` or `WeakSet`.
78+
79+
---
80+
81+
By using the `Set` or `WeakSet` constructor with the `new` keyword
82+
83+
## --video-solution--
84+
85+
4
86+
87+
## --text--
88+
89+
Which methods are available to both a `Set` and a `WeakSet` in JavaScript?
90+
91+
## --answers--
92+
93+
`keys()`, `values()`, `size()`
94+
95+
### --feedback--
96+
97+
Review the end of the video where this was discussed.
98+
99+
---
100+
101+
`add()`, `delete()`, `has()`
102+
103+
---
104+
105+
`clear()`, `entries()`, `forEach()`
106+
107+
### --feedback--
108+
109+
Review the end of the video where this was discussed.
110+
111+
---
112+
113+
`set()`, `get()`, `remove()`
114+
115+
### --feedback--
116+
117+
Review the end of the video where this was discussed.
30118

31119
## --video-solution--
32120

33-
1
121+
2

curriculum/challenges/english/25-front-end-development/lecture-working-with-maps-and-sets/6733dd694f91d61a5272b4ac.md

Lines changed: 93 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,108 @@ Watch the lecture video and answer the questions below.
1414

1515
## --text--
1616

17-
What Is the Map Object, and How Does It Differ from WeakMaps? question?
17+
Which of these differentiates a `Map` from a `WeakMap` in JavaScript?
1818

1919
## --answers--
2020

21-
Answer 1
21+
A `Map` allows only objects as keys, while a `WeakMap` allows keys of any type.
22+
23+
### --feedback--
24+
25+
Think about the key types allowed and how the references are handled.
26+
27+
---
28+
29+
A `Map` has weak references to keys, while a `WeakMap` does not.
30+
31+
### --feedback--
32+
33+
Think about the key types allowed and how the references are handled.
2234

2335
---
2436

25-
Answer 2
37+
A `Map` allows keys of any type, while a `WeakMap` only allows objects as keys.
2638

2739
---
2840

29-
Answer 3
41+
A `Map` and a `WeakMap` function exactly the same.
42+
43+
### --feedback--
44+
45+
Think about the key types allowed and how the references are handled.
46+
47+
## --video-solution--
48+
49+
3
50+
51+
## --text--
52+
53+
Which property lets you know the number of items in a `Map`?
54+
55+
## --answers--
56+
57+
`length`
58+
59+
### --feedback--
60+
61+
Think about the property that measures the number of entries in a `Map`.
62+
63+
---
64+
65+
`count`
66+
67+
### --feedback--
68+
69+
Think about the property that measures the number of entries in a `Map`.
70+
71+
---
72+
73+
`total`
74+
75+
### --feedback--
76+
77+
Think about the property that measures the number of entries in a `Map`.
78+
79+
---
80+
81+
`size`
82+
83+
## --video-solution--
84+
85+
4
86+
87+
## --text--
88+
89+
Which method lets you add an item to a `Map` and a `WeakMap`?
90+
91+
## --answers--
92+
93+
`add()`
94+
95+
### --feedback--
96+
97+
Think about the method specifically used for adding key-value pairs to a `Map`.
98+
99+
---
100+
101+
`push()`
102+
103+
### --feedback--
104+
105+
Think about the method specifically used for adding key-value pairs to a `Map`.
106+
107+
---
108+
109+
`set()`
110+
111+
---
112+
113+
`insert()`
114+
115+
### --feedback--
116+
117+
Think about the method specifically used for adding key-value pairs to a `Map`.
30118

31119
## --video-solution--
32120

33-
1
121+
3

0 commit comments

Comments
 (0)