Last active
October 1, 2023 23:31
-
-
Save carlosrojaso/a3adf04753bdaba24a0b2d31d1a45164 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
class Ingredient { | |
constructor(name) { | |
this.name = name; | |
} | |
getInfo() { | |
return `I'm a ${this.name}` | |
} | |
} | |
class Ingredients { | |
constructor() { | |
this.ingredients = {}; | |
} | |
create(name) { | |
let ingredient = this.ingredients[name]; | |
if (ingredient) return ingredient; | |
this.ingredients[name] = new Ingredient(name); | |
return this.ingredients[name]; | |
} | |
} | |
export { Ingredients }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment