Skip to content

Instantly share code, notes, and snippets.

@caominhdev
Created May 11, 2022 03:14
Show Gist options
  • Save caominhdev/6c8aaeb46db2cd5e04abb4f0ae760243 to your computer and use it in GitHub Desktop.
Save caominhdev/6c8aaeb46db2cd5e04abb4f0ae760243 to your computer and use it in GitHub Desktop.
inventoryList
function inventoryList() {
return {
items: [],
add: function (name) {
if (this.items.includes(name)) {
return
}
this.items.push(name)
},
remove: function (name) {
if (this.items.includes(name)) {
let index = this.items.indexOf(name);
if (index > -1) {
this.items.splice(index, 1)
}
}
},
getList: function () {
return this.items;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment