Hướng dẫn thử thách
1 / 1
Implement a Matching Object Filter
In this lab, you will create a function that filters an array of objects and returns only those objects that match all key-value pairs in a given source object.
**Objective**: Fulfill the user stories below and get all the tests to pass to complete the lab.
**User Stories:**
1. You should have a `whatIsInAName` function that accepts two arguments, an array of objects and a source object.
1. The `whatIsInAName` function should return a new array containing only the objects from the collection that have all the key–value pairs present in the source object.
1. If no objects match all the key–value pairs from the source, the function should return an empty array. For example:
```js
whatIsInAName(
[
{ first: "Romeo", last: "Montague" },
{ first: "Mercutio", last: null },
{ first: "Tybalt", last: "Capulet" }
],
{ last: "Capulet" }
);
// should return [{ first: "Tybalt", last: "Capulet" }]
```
Vượt qua bài kiểm tra hiện tại để mở khóa bài tiếp theo.
main.js
UTF-8 • Tab Size: 2Kiểm tra bài:⌘↵