Created
July 27, 2019 07:45
-
-
Save jasongorman/fcd7eb8928003afc87e5a36df90d9bac 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) { | |
this.contents = contents; | |
} | |
search(title, artist){ | |
return this.contents | |
.filter((cd) => | |
cd.matches(title, artist))[0]; | |
} | |
receive(batch){ | |
const {title, artist, copies} = batch.cds[0]; | |
const cd = this.search(title, artist); | |
cd.stock += copies; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment