2018-10-04 14:37:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								---
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								id: a8e512fbe388ac2f9198f0fa
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								title: Wherefore art thou
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								challengeType: 5
							 
						 
					
						
							
								
									
										
										
										
											2019-07-31 11:32:23 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								forumTopicId: 16092
							 
						 
					
						
							
								
									
										
										
										
											2021-01-13 03:31:00 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								dashedName: wherefore-art-thou
							 
						 
					
						
							
								
									
										
										
										
											2018-10-04 14:37:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								---
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-27 19:02:05 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# --description--
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-10-04 14:37:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								Make a function that looks through an array of objects (first argument) and returns an array of all objects that have matching name and value pairs (second argument). Each name and value pair of the source object has to be present in the object from the collection if it is to be included in the returned array.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-27 19:02:05 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								For example, if the first argument is `[{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }]` , and the second argument is `{ last: "Capulet" }` , then you must return the third object from the array (the first argument), because it contains the name and its value, that was passed on as the second argument.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# --hints--
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								`whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" })`  should return `[{ first: "Tybalt", last: "Capulet" }]` .
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```js
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								assert.deepEqual(
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  whatIsInAName(
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    [
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      { first: 'Romeo', last: 'Montague' },
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      { first: 'Mercutio', last: null },
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      { first: 'Tybalt', last: 'Capulet' }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    ],
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    { last: 'Capulet' }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  ),
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  [{ first: 'Tybalt', last: 'Capulet' }]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								`whatIsInAName([{ "apple": 1 }, { "apple": 1 }, { "apple": 1, "bat": 2 }], { "apple": 1 })`  should return `[{ "apple": 1 }, { "apple": 1 }, { "apple": 1, "bat": 2 }]` .
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```js
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								assert.deepEqual(
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  whatIsInAName([{ apple: 1 }, { apple: 1 }, { apple: 1, bat: 2 }], {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    apple: 1
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  }),
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  [{ apple: 1 }, { apple: 1 }, { apple: 1, bat: 2 }]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								`whatIsInAName([{ "apple": 1, "bat": 2 }, { "bat": 2 }, { "apple": 1, "bat": 2, "cookie": 2 }], { "apple": 1, "bat": 2 })`  should return `[{ "apple": 1, "bat": 2 }, { "apple": 1, "bat": 2, "cookie": 2 }]` .
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```js
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								assert.deepEqual(
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  whatIsInAName(
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    [{ apple: 1, bat: 2 }, { bat: 2 }, { apple: 1, bat: 2, cookie: 2 }],
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    { apple: 1, bat: 2 }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  ),
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  [
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    { apple: 1, bat: 2 },
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    { apple: 1, bat: 2, cookie: 2 }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  ]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								`whatIsInAName([{ "apple": 1, "bat": 2 }, { "apple": 1 }, { "apple": 1, "bat": 2, "cookie": 2 }], { "apple": 1, "cookie": 2 })`  should return `[{ "apple": 1, "bat": 2, "cookie": 2 }]` .
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```js
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								assert.deepEqual(
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  whatIsInAName(
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    [{ apple: 1, bat: 2 }, { apple: 1 }, { apple: 1, bat: 2, cookie: 2 }],
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    { apple: 1, cookie: 2 }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  ),
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  [{ apple: 1, bat: 2, cookie: 2 }]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								);
							 
						 
					
						
							
								
									
										
										
										
											2018-10-04 14:37:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-27 19:02:05 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								`whatIsInAName([{ "apple": 1, "bat": 2 }, { "apple": 1 }, { "apple": 1, "bat": 2, "cookie": 2 }, { "bat":2 }], { "apple": 1, "bat": 2 })`  should return `[{ "apple": 1, "bat": 2 }, { "apple": 1, "bat": 2, "cookie":2 }]` .
							 
						 
					
						
							
								
									
										
										
										
											2018-10-04 14:37:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-27 19:02:05 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								```js
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								assert.deepEqual(
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  whatIsInAName(
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    [
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      { apple: 1, bat: 2 },
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      { apple: 1 },
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      { apple: 1, bat: 2, cookie: 2 },
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      { bat: 2 }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    ],
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    { apple: 1, bat: 2 }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  ),
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  [
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    { apple: 1, bat: 2 },
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    { apple: 1, bat: 2, cookie: 2 }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  ]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2018-10-04 14:37:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-27 19:02:05 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								`whatIsInAName([{"a": 1, "b": 2, "c": 3}], {"a": 1, "b": 9999, "c": 3})`  should return `[]` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```js
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								assert.deepEqual(
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  whatIsInAName([{ a: 1, b: 2, c: 3 }], { a: 1, b: 9999, c: 3 }),
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  []
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# --seed--
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								## --seed-contents--
 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-04 14:37:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```js
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								function whatIsInAName(collection, source) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  var arr = [];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  // Only change code below this line
							 
						 
					
						
							
								
									
										
										
										
											2018-10-08 01:01:53 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-10-04 14:37:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								  // Only change code above this line
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  return arr;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-27 19:02:05 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# --solutions--
 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-04 14:37:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```js
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								function whatIsInAName(collection, source) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  var arr = [];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  var keys = Object.keys(source);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  collection.forEach(function(e) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if(keys.every(function(key) {return e[key] === source[key];})) {
							 
						 
					
						
							
								
									
										
										
										
											2018-10-08 01:01:53 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      arr.push(e);
							 
						 
					
						
							
								
									
										
										
										
											2018-10-04 14:37:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  });
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  return arr;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```