Created
July 27, 2019 10:54
-
-
Save jasongorman/0e2ee37f122b80a6208b818953f38dca to your computer and use it in GitHub Desktop.
This file contains 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
class Catalogue { | |
constructor(contents, cdFactory) { | |
this.contents = contents; | |
this.cdFactory = cdFactory; | |
} | |
search(title, artist){ | |
return this.contents | |
.filter((cd) => | |
cd.matches(title, artist))[0]; | |
} | |
add(received){ | |
const cd = this.cdFactory.createCd(received); | |
this.contents.push(cd); | |
return cd; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment