mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-04-13 22:00:19 -04:00
feat(curriculum): add missing quizzes (#57210)
This commit is contained in:
@@ -3094,7 +3094,12 @@
|
||||
"Review the JavaScript Maps, Sets, and JSON concepts to prepare for the upcoming quiz."
|
||||
]
|
||||
},
|
||||
"cvs3": { "title": "229", "intro": [] },
|
||||
"quiz-javascript-maps-sets-and-json": {
|
||||
"title": "JavaScript Maps, Sets, and JSON Quiz",
|
||||
"intro": [
|
||||
"Test what you've learned in this quiz on JavaScript Maps, Sets, and JSON."
|
||||
]
|
||||
},
|
||||
"lecture-working-with-client-side-storage-and-crud-operations": {
|
||||
"title": "Working with Client-Side Storage and CRUD Operations",
|
||||
"intro": [
|
||||
@@ -3150,7 +3155,12 @@
|
||||
"Review the JavaScript Classes concepts to prepare for the upcoming quiz."
|
||||
]
|
||||
},
|
||||
"ndl1": { "title": "240", "intro": [] },
|
||||
"quiz-javascript-classes": {
|
||||
"title": "JavaScript Classes Quiz",
|
||||
"intro": [
|
||||
"Test what you've learned in this quiz on JavaScript Classes."
|
||||
]
|
||||
},
|
||||
"lecture-understanding-recursion-and-the-call-stack": {
|
||||
"title": "Understanding Recursion and the Call Stack",
|
||||
"intro": [
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
---
|
||||
title: Introduction to the JavaScript Classes Quiz
|
||||
block: quiz-javascript-classes
|
||||
superBlock: full-stack-developer
|
||||
---
|
||||
|
||||
## Introduction to the JavaScript Classes Quiz
|
||||
|
||||
Test what you've learned in this quiz on JavaScript Classes.
|
||||
@@ -0,0 +1,9 @@
|
||||
---
|
||||
title: Introduction to the JavaScript Maps, Sets, and JSON Quiz
|
||||
block: quiz-javascript-maps-sets-and-json
|
||||
superBlock: full-stack-developer
|
||||
---
|
||||
|
||||
## Introduction to the JavaScript Maps, Sets, and JSON Quiz
|
||||
|
||||
Test what you've learned in this quiz on JavaScript Maps, Sets, and JSON.
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"name": "JavaScript Classes Quiz",
|
||||
"blockType": "quiz",
|
||||
"blockLayout": "link",
|
||||
"isUpcomingChange": true,
|
||||
"dashedName": "quiz-javascript-classes",
|
||||
"superBlock": "full-stack-developer",
|
||||
"challengeOrder": [
|
||||
{ "id": "67358ac128957c865dcf3ddf", "title": "JavaScript Classes Quiz" }
|
||||
],
|
||||
"helpCategory": "JavaScript"
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "JavaScript Maps, Sets, and JSON Quiz",
|
||||
"blockType": "quiz",
|
||||
"blockLayout": "link",
|
||||
"isUpcomingChange": true,
|
||||
"dashedName": "quiz-javascript-maps-sets-and-json",
|
||||
"superBlock": "full-stack-developer",
|
||||
"challengeOrder": [
|
||||
{
|
||||
"id": "67358be1c7903489c0a7db78",
|
||||
"title": "JavaScript Maps, Sets, and JSON Quiz"
|
||||
}
|
||||
],
|
||||
"helpCategory": "JavaScript"
|
||||
}
|
||||
@@ -0,0 +1,515 @@
|
||||
---
|
||||
id: 67358ac128957c865dcf3ddf
|
||||
title: JavaScript Classes Quiz
|
||||
challengeType: 8
|
||||
dashedName: quiz-javascript-classes
|
||||
---
|
||||
|
||||
# --description--
|
||||
|
||||
To pass the quiz, you must correctly answer at least 17 of the 20 of the questions below.
|
||||
|
||||
# --quizzes--
|
||||
|
||||
## --quiz--
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
What is the purpose of a class in JavaScript?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
To define only properties, not methods.
|
||||
|
||||
---
|
||||
|
||||
To define static variables only.
|
||||
|
||||
---
|
||||
|
||||
To organize only primitive data.
|
||||
|
||||
#### --answer--
|
||||
|
||||
To create reusable blueprints for objects.
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
How do you define a class in JavaScript?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Using the `className` keyword.
|
||||
|
||||
---
|
||||
|
||||
Using the `object` keyword.
|
||||
|
||||
---
|
||||
|
||||
Using the `constructor` keyword only.
|
||||
|
||||
#### --answer--
|
||||
|
||||
Using the `class` keyword.
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Which method is used in a class to initialize properties?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
`static`
|
||||
|
||||
---
|
||||
|
||||
`init`
|
||||
|
||||
---
|
||||
|
||||
`define`
|
||||
|
||||
#### --answer--
|
||||
|
||||
`constructor`
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
What does `this` represent inside a class constructor?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
The global object.
|
||||
|
||||
---
|
||||
|
||||
The function itself.
|
||||
|
||||
---
|
||||
|
||||
An undefined reference.
|
||||
|
||||
#### --answer--
|
||||
|
||||
The instance of the class being created.
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Which of the following describes how `this` behaves in an arrow function inside a class method?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
It refers to the method calling the arrow function.
|
||||
|
||||
---
|
||||
|
||||
It refers to a newly created instance of the class.
|
||||
|
||||
---
|
||||
|
||||
It refers to `undefined` by default.
|
||||
|
||||
#### --answer--
|
||||
|
||||
It inherits the value of `this` from the enclosing scope where they are defined.
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
What is the primary purpose of the `extends` keyword?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
To define static methods in a class.
|
||||
|
||||
---
|
||||
|
||||
To create a method in a class.
|
||||
|
||||
---
|
||||
|
||||
To initialize properties in the parent class.
|
||||
|
||||
#### --answer--
|
||||
|
||||
To create a subclass that inherits methods from a parent class.
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Which of the following is an example of how to create a `Car` class that inherits from a `Vehicle` class?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
```javascript
|
||||
class Car uses Vehicle {}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```javascript
|
||||
class Car = Vehicle {}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```javascript
|
||||
class Car inherits Vehicle {}
|
||||
```
|
||||
|
||||
#### --answer--
|
||||
|
||||
```javascript
|
||||
class Car extends Vehicle {}
|
||||
```
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
What is the output of the following code?
|
||||
|
||||
```javascript
|
||||
class Animal {
|
||||
speak() {
|
||||
return "Animal speaks";
|
||||
}
|
||||
}
|
||||
|
||||
class Dog extends Animal {
|
||||
speak() {
|
||||
return "Dog barks";
|
||||
}
|
||||
}
|
||||
|
||||
const myDog = new Dog();
|
||||
console.log(myDog.speak());
|
||||
```
|
||||
|
||||
#### --distractors--
|
||||
|
||||
`Animal speaks`
|
||||
|
||||
---
|
||||
|
||||
An error is raised.
|
||||
|
||||
---
|
||||
|
||||
`undefined`
|
||||
|
||||
#### --answer--
|
||||
|
||||
`Dog barks`
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
What is the function of the `super` keyword in a subclass?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
To define a new instance of a class.
|
||||
|
||||
---
|
||||
|
||||
To delete properties from a class.
|
||||
|
||||
---
|
||||
|
||||
To access only the static methods of a class.
|
||||
|
||||
#### --answer--
|
||||
|
||||
To call the constructor or methods of the parent class.
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Which of the following describes a static method?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
A method that is inaccessible inside the class itself.
|
||||
|
||||
---
|
||||
|
||||
A method that is used only in arrow functions.
|
||||
|
||||
---
|
||||
|
||||
A method that is unique to each instance of a class.
|
||||
|
||||
#### --answer--
|
||||
|
||||
A method that belongs to the class itself, not to any instance.
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
What will the following code output?
|
||||
|
||||
```js
|
||||
class Calculator {
|
||||
static add(a, b) {
|
||||
return a + b;
|
||||
}
|
||||
}
|
||||
|
||||
console.log(Calculator.add(3, 4));
|
||||
```
|
||||
|
||||
#### --distractors--
|
||||
|
||||
An error is raised.
|
||||
|
||||
---
|
||||
|
||||
`undefined`
|
||||
|
||||
---
|
||||
|
||||
`NaN`
|
||||
|
||||
#### --answer--
|
||||
|
||||
`7`
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
How would you access a static property in JavaScript class?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
By using `this.propertyName` within a method.
|
||||
|
||||
---
|
||||
|
||||
By using `instance.propertyName` after creating an instance.
|
||||
|
||||
---
|
||||
|
||||
By using `super.propertyName` within a subclass.
|
||||
|
||||
#### --answer--
|
||||
|
||||
By using `ClassName.propertyName`.
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
In which scenario would you use a static method over an instance method?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
When you need to access and modify the instance's properties.
|
||||
|
||||
---
|
||||
|
||||
When the method needs to be called on an object instance.
|
||||
|
||||
---
|
||||
|
||||
When the method doesn't rely on instance-specific data and operates on class-level data.
|
||||
|
||||
#### --answer--
|
||||
|
||||
When the method operates on data that is shared by all instances of the class.
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
What will the following code output?
|
||||
|
||||
```js
|
||||
class MyClass {
|
||||
sayHello() {
|
||||
return "Hello!";
|
||||
}
|
||||
}
|
||||
|
||||
console.log(MyClass.sayHello());
|
||||
```
|
||||
|
||||
#### --distractors--
|
||||
|
||||
`Hello!`
|
||||
|
||||
---
|
||||
|
||||
`null`
|
||||
|
||||
---
|
||||
|
||||
`undefined`
|
||||
|
||||
#### --answer--
|
||||
|
||||
It throws an error.
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
What keyword is used to inherit properties and methods from another class?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
`import`
|
||||
|
||||
---
|
||||
|
||||
`inherit`
|
||||
|
||||
---
|
||||
|
||||
`static`
|
||||
|
||||
#### --answer--
|
||||
|
||||
`extends`
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
What is printed by the following code?
|
||||
|
||||
```js
|
||||
class Person {
|
||||
static species = "Human";
|
||||
}
|
||||
|
||||
console.log(Person.species);
|
||||
```
|
||||
|
||||
#### --distractors--
|
||||
|
||||
`undefined`
|
||||
|
||||
---
|
||||
|
||||
`null`
|
||||
|
||||
---
|
||||
|
||||
An error is raised.
|
||||
|
||||
#### --answer--
|
||||
|
||||
`Human`
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Which of the following best describes inheritance?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
It allows a method to return a new object.
|
||||
|
||||
---
|
||||
|
||||
It allows an instance to define its own properties.
|
||||
|
||||
---
|
||||
|
||||
It allows a static property to be converted into a non-static property.
|
||||
|
||||
#### --answer--
|
||||
|
||||
It allows a class to acquire properties and methods from another class.
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
What happens if a constructor is not defined in a subclass?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
An error will be thrown.
|
||||
|
||||
---
|
||||
|
||||
The subclass will inherit the constructor from any class in the code.
|
||||
|
||||
---
|
||||
|
||||
The subclass cannot create new instances.
|
||||
|
||||
#### --answer--
|
||||
|
||||
The superclass’s constructor will be used by default.
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
What does `this` represent in the following code?
|
||||
|
||||
```js
|
||||
class Animal {
|
||||
constructor(name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### --distractors--
|
||||
|
||||
The global object.
|
||||
|
||||
---
|
||||
|
||||
The `Animal` class itself.
|
||||
|
||||
---
|
||||
|
||||
An undefined variable.
|
||||
|
||||
#### --answer--
|
||||
|
||||
The specific instance of `Animal` being created.
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
What is the primary use of static properties?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
To set default values for each instance.
|
||||
|
||||
---
|
||||
|
||||
To override methods in a subclass.
|
||||
|
||||
---
|
||||
|
||||
To define instance-specific data.
|
||||
|
||||
#### --answer--
|
||||
|
||||
To store class-wide data that remains constant across instances.
|
||||
@@ -0,0 +1,478 @@
|
||||
---
|
||||
id: 67358be1c7903489c0a7db78
|
||||
title: JavaScript Maps, Sets, and JSON Quiz
|
||||
challengeType: 8
|
||||
dashedName: quiz-javascript-maps-sets-and-json
|
||||
---
|
||||
|
||||
# --description--
|
||||
|
||||
To pass the quiz, you must correctly answer at least 17 of the 20 of the questions below.
|
||||
|
||||
# --quizzes--
|
||||
|
||||
## --quiz--
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
What is a Set in JavaScript?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
A data structure that allows duplicate values.
|
||||
|
||||
---
|
||||
|
||||
A data structure that only stores strings and numbers.
|
||||
|
||||
---
|
||||
|
||||
A collection that does not allow deletion of its elements.
|
||||
|
||||
#### --answer--
|
||||
|
||||
A collection of unique values, where each value can only occur once.
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Which of the following is NOT a characteristic of a JavaScript Set?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
It stores elements in insertion order.
|
||||
|
||||
---
|
||||
|
||||
It only stores unique values.
|
||||
|
||||
---
|
||||
|
||||
It allows iteration.
|
||||
|
||||
#### --answer--
|
||||
|
||||
It allows duplicate values.
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
What method is used to add elements to a Set?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
`.push()`
|
||||
|
||||
---
|
||||
|
||||
`.append()`
|
||||
|
||||
---
|
||||
|
||||
`.insert()`
|
||||
|
||||
#### --answer--
|
||||
|
||||
`.add()`
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
How do you check if a Set contains a certain value?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
`.contains()`
|
||||
|
||||
---
|
||||
|
||||
`.hasValue()`
|
||||
|
||||
---
|
||||
|
||||
`.find()`
|
||||
|
||||
#### --answer--
|
||||
|
||||
`.has()`
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
What will the following code output?
|
||||
|
||||
```js
|
||||
const mySet = new Set([1, 1, 2, 3]);
|
||||
console.log(mySet.size);
|
||||
```
|
||||
|
||||
#### --distractors--
|
||||
|
||||
4
|
||||
|
||||
---
|
||||
|
||||
0
|
||||
|
||||
---
|
||||
|
||||
1
|
||||
|
||||
#### --answer--
|
||||
|
||||
3
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
What is a WeakSet in JavaScript?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
A Set-like collection that only allows primitive data types.
|
||||
|
||||
---
|
||||
|
||||
A Set-like collection that allows duplicate values.
|
||||
|
||||
---
|
||||
|
||||
A Set-like collection that prevents values from being removed.
|
||||
|
||||
#### --answer--
|
||||
|
||||
A Set-like collection that only stores objects and allows garbage collection.
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
What is one difference between a Set and a WeakSet?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
A WeakSet can store any type of value, including numbers.
|
||||
|
||||
---
|
||||
|
||||
A Set does not allow duplicate values, but a WeakSet does.
|
||||
|
||||
---
|
||||
|
||||
A Set allows garbage collection, whereas a WeakSet does not.
|
||||
|
||||
#### --answer--
|
||||
|
||||
A Set can hold any type of value, while a WeakSet only holds objects.
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
What is a Map in JavaScript?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
A collection that only allows unique values.
|
||||
|
||||
---
|
||||
|
||||
A collection that can only use strings as keys.
|
||||
|
||||
---
|
||||
|
||||
A collection that does not allow deletion of its items.
|
||||
|
||||
#### --answer--
|
||||
|
||||
A collection of key-value pairs of any type.
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
What method is used to insert key-value pairs into a Map?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
`.append()`
|
||||
|
||||
---
|
||||
|
||||
`.add()`
|
||||
|
||||
---
|
||||
|
||||
`.insert()`
|
||||
|
||||
#### --answer--
|
||||
|
||||
`.set()`
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
What will the following code output?
|
||||
|
||||
```js
|
||||
const myMap = new Map();
|
||||
myMap.set('a', 1);
|
||||
myMap.set('a', 2);
|
||||
console.log(myMap.get('a'));
|
||||
```
|
||||
|
||||
#### --distractors--
|
||||
|
||||
`1`
|
||||
|
||||
---
|
||||
|
||||
`undefined`
|
||||
|
||||
---
|
||||
|
||||
`null`
|
||||
|
||||
#### --answer--
|
||||
|
||||
`2`
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
How does a Map differ from an Object in JavaScript?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
A Map only allows numbers as keys.
|
||||
|
||||
---
|
||||
|
||||
Objects allow any type as keys, while Maps only allow strings.
|
||||
|
||||
---
|
||||
|
||||
Maps do not support iteration, while Objects do.
|
||||
|
||||
#### --answer--
|
||||
|
||||
Maps allow any type of key, but Objects only allow strings and symbols.
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
How can you remove a key-value pair from a Map?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
`.remove()`
|
||||
|
||||
---
|
||||
|
||||
`.deleteKey()`
|
||||
|
||||
---
|
||||
|
||||
`.erase()`
|
||||
|
||||
#### --answer--
|
||||
|
||||
`.delete()`
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
What does the `size` property of a Map return?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
The number of unique keys in the Map.
|
||||
|
||||
---
|
||||
|
||||
The number of unique values in the Map.
|
||||
|
||||
---
|
||||
|
||||
The total memory used by the Map.
|
||||
|
||||
#### --answer--
|
||||
|
||||
The number of key-value pairs in the Map.
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
What is a WeakMap in JavaScript?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
A Map-like collection that allows primitive values as keys.
|
||||
|
||||
---
|
||||
|
||||
A Map-like collection that blocks the deletion of items.
|
||||
|
||||
---
|
||||
|
||||
A Map-like collection that automatically sorts its keys.
|
||||
|
||||
#### --answer--
|
||||
|
||||
A Map-like collection with objects as keys that allows garbage collection.
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
What is one difference between a Map and a WeakMap?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
A Map allows only primitive types as keys, whereas a WeakMap only allows objects.
|
||||
|
||||
---
|
||||
|
||||
A Map allows garbage collection, whereas a WeakMap does not.
|
||||
|
||||
---
|
||||
|
||||
A WeakMap allows duplicate keys, whereas a Map does not.
|
||||
|
||||
#### --answer--
|
||||
|
||||
A Map is iterable, whereas a WeakMap is not.
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Which of the following methods does NOT exist on a WeakMap?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
`.has()`
|
||||
|
||||
---
|
||||
|
||||
`.set()`
|
||||
|
||||
---
|
||||
|
||||
`.delete()`
|
||||
|
||||
#### --answer--
|
||||
|
||||
`.size()`
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
What will be the output of the following code?
|
||||
|
||||
```js
|
||||
const set = new Set([1, 2, 3]);
|
||||
set.delete(2);
|
||||
console.log(set.has(2));
|
||||
```
|
||||
|
||||
#### --distractors--
|
||||
|
||||
`true`
|
||||
|
||||
---
|
||||
|
||||
`undefined`
|
||||
|
||||
---
|
||||
|
||||
`2`
|
||||
|
||||
#### --answer--
|
||||
|
||||
`false`
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
How can you iterate over the values in a Set?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Using `.forEach()`, or `.map()`.
|
||||
|
||||
---
|
||||
|
||||
Using `.reduce()` or `.filter()`.
|
||||
|
||||
---
|
||||
|
||||
Using `.keys()` or a loop.
|
||||
|
||||
#### --answer--
|
||||
|
||||
Using `.forEach()` or a loop.
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
What does `Map.prototype.get()` do?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
It retrieves all keys in the Map.
|
||||
|
||||
---
|
||||
|
||||
It sets a new key-value pair in the Map.
|
||||
|
||||
---
|
||||
|
||||
It returns the size of the Map.
|
||||
|
||||
#### --answer--
|
||||
|
||||
It retrieves the value for a specified key.
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
What will be the output of the following code?
|
||||
|
||||
```js
|
||||
const map = new Map([["a", 1], ["b", 2]]);
|
||||
map.clear();
|
||||
console.log(map.size);
|
||||
```
|
||||
|
||||
#### --distractors--
|
||||
|
||||
`2`
|
||||
|
||||
---
|
||||
|
||||
`1`
|
||||
|
||||
---
|
||||
|
||||
`undefined`
|
||||
|
||||
#### --answer--
|
||||
|
||||
`0`
|
||||
@@ -464,7 +464,8 @@
|
||||
"dashedName": "maps-sets-and-json",
|
||||
"blocks": [
|
||||
{ "dashedName": "lecture-working-with-maps-and-sets" },
|
||||
{ "dashedName": "review-javascript-maps-sets-and-json" }
|
||||
{ "dashedName": "review-javascript-maps-sets-and-json" },
|
||||
{ "dashedName": "quiz-javascript-maps-sets-and-json" }
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -487,7 +488,8 @@
|
||||
},
|
||||
{ "dashedName": "workshop-shopping-cart" },
|
||||
{ "dashedName": "lab-project-idea-board" },
|
||||
{ "dashedName": "review-javascript-classes" }
|
||||
{ "dashedName": "review-javascript-classes" },
|
||||
{ "dashedName": "quiz-javascript-classes" }
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user