Created
January 22, 2022 02:32
-
-
Save delta48/e8ef5cfab6468dd2a22d6b8dd85912eb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| solution for | |
| https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/wherefore-art-thou | |
| */ | |
| function whatIsInAName(collection, source) { | |
| const arr = []; | |
| // Only change code below this line | |
| arr.push(...collection.filter(el => Object.keys(source).every(key => (key in el && el[key] === source[key])))) | |
| // Only change code above this line | |
| return arr; | |
| } | |
| whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment