Skip to content

Instantly share code, notes, and snippets.

@jasongorman
Created July 27, 2019 09:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasongorman/2aae183cc6414fa10929bcb08c377541 to your computer and use it in GitHub Desktop.
Save jasongorman/2aae183cc6414fa10929bcb08c377541 to your computer and use it in GitHub Desktop.
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