Created
July 27, 2019 09:30
-
-
Save jasongorman/2aae183cc6414fa10929bcb08c377541 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(title, artist){ | |
const cd = this.cdFactory.createCd(title, artist); | |
this.contents.push(cd); | |
return cd; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment