Skip to content

Instantly share code, notes, and snippets.

@carlosrojaso
Last active October 1, 2023 23:31
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 carlosrojaso/a3adf04753bdaba24a0b2d31d1a45164 to your computer and use it in GitHub Desktop.
Save carlosrojaso/a3adf04753bdaba24a0b2d31d1a45164 to your computer and use it in GitHub Desktop.
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