From d33f504ea704bc8b3634105dcb7e39dea16db2f9 Mon Sep 17 00:00:00 2001 From: Jessica Wilkins <67210629+jdwilkin4@users.noreply.github.com> Date: Tue, 26 Nov 2024 14:04:49 -0800 Subject: [PATCH] chore(curriculum): adding questions for maps and sets lecture (#57319) --- .../6733ab269b378bf724c9ac71.md | 98 ++++++++++++++++++- .../6733dd694f91d61a5272b4ac.md | 98 ++++++++++++++++++- 2 files changed, 186 insertions(+), 10 deletions(-) diff --git a/curriculum/challenges/english/25-front-end-development/lecture-working-with-maps-and-sets/6733ab269b378bf724c9ac71.md b/curriculum/challenges/english/25-front-end-development/lecture-working-with-maps-and-sets/6733ab269b378bf724c9ac71.md index 677189f302e..e685e1c792d 100644 --- a/curriculum/challenges/english/25-front-end-development/lecture-working-with-maps-and-sets/6733ab269b378bf724c9ac71.md +++ b/curriculum/challenges/english/25-front-end-development/lecture-working-with-maps-and-sets/6733ab269b378bf724c9ac71.md @@ -14,20 +14,108 @@ Watch the video lecture and answer the questions below. ## --text-- -What Is the Map Object, and How Does It Differ from WeakMaps? question? +How does a `Set` differ from a `WeakSet` when it comes to the data they both support? ## --answers-- -Answer 1 +A `Set` allows weakly held object references, while a `WeakSet` supports both objects and primitives. + +### --feedback-- + +Remember that a `Set` can hold a variety of data types. --- -Answer 2 +A `Set` stores any type, including primitives, while a `WeakSet` allows only weakly held object references. --- -Answer 3 +A `Set` has fewer features than a `WeakSet`. + +### --feedback-- + +Remember that a `Set` can hold a variety of data types. + +--- + +A `Set` is exclusively for objects, while a `WeakSet` is for numbers. + +### --feedback-- + +Remember that a `Set` can hold a variety of data types. ## --video-solution-- -1 +2 + +## --text-- + +How do you create a `Set` or a `WeakSet` in JavaScript? + +## --answers-- + +By calling `Set()` or `WeakSet()` without the `new` keyword + +### --feedback-- + +Think about what keyword needs to be included to create a `Set` or `WeakSet`. + +--- + +By using object literals `{}` + +### --feedback-- + +Think about what keyword needs to be included to create a `Set` or `WeakSet`. + +--- + +By using array literals `[]` + +### --feedback-- + +Think about what keyword needs to be included to create a `Set` or `WeakSet`. + +--- + +By using the `Set` or `WeakSet` constructor with the `new` keyword + +## --video-solution-- + +4 + +## --text-- + +Which methods are available to both a `Set` and a `WeakSet` in JavaScript? + +## --answers-- + +`keys()`, `values()`, `size()` + +### --feedback-- + +Review the end of the video where this was discussed. + +--- + +`add()`, `delete()`, `has()` + +--- + +`clear()`, `entries()`, `forEach()` + +### --feedback-- + +Review the end of the video where this was discussed. + +--- + +`set()`, `get()`, `remove()` + +### --feedback-- + +Review the end of the video where this was discussed. + +## --video-solution-- + +2 diff --git a/curriculum/challenges/english/25-front-end-development/lecture-working-with-maps-and-sets/6733dd694f91d61a5272b4ac.md b/curriculum/challenges/english/25-front-end-development/lecture-working-with-maps-and-sets/6733dd694f91d61a5272b4ac.md index bc62d2834ed..f09c5a81584 100644 --- a/curriculum/challenges/english/25-front-end-development/lecture-working-with-maps-and-sets/6733dd694f91d61a5272b4ac.md +++ b/curriculum/challenges/english/25-front-end-development/lecture-working-with-maps-and-sets/6733dd694f91d61a5272b4ac.md @@ -14,20 +14,108 @@ Watch the lecture video and answer the questions below. ## --text-- -What Is the Map Object, and How Does It Differ from WeakMaps? question? +Which of these differentiates a `Map` from a `WeakMap` in JavaScript? ## --answers-- -Answer 1 +A `Map` allows only objects as keys, while a `WeakMap` allows keys of any type. + +### --feedback-- + +Think about the key types allowed and how the references are handled. --- -Answer 2 +A `Map` has weak references to keys, while a `WeakMap` does not. + +### --feedback-- + +Think about the key types allowed and how the references are handled. --- -Answer 3 +A `Map` allows keys of any type, while a `WeakMap` only allows objects as keys. + +--- + +A `Map` and a `WeakMap` function exactly the same. + +### --feedback-- + +Think about the key types allowed and how the references are handled. ## --video-solution-- -1 +3 + +## --text-- + +Which property lets you know the number of items in a `Map`? + +## --answers-- + +`length` + +### --feedback-- + +Think about the property that measures the number of entries in a `Map`. + +--- + +`count` + +### --feedback-- + +Think about the property that measures the number of entries in a `Map`. + +--- + +`total` + +### --feedback-- + +Think about the property that measures the number of entries in a `Map`. + +--- + +`size` + +## --video-solution-- + +4 + +## --text-- + +Which method lets you add an item to a `Map` and a `WeakMap`? + +## --answers-- + +`add()` + +### --feedback-- + +Think about the method specifically used for adding key-value pairs to a `Map`. + +--- + +`push()` + +### --feedback-- + +Think about the method specifically used for adding key-value pairs to a `Map`. + +--- + +`set()` + +--- + +`insert()` + +### --feedback-- + +Think about the method specifically used for adding key-value pairs to a `Map`. + +## --video-solution-- + +3