I want to make a sort of "shopping list" in JS. I'm having trouble accessing the object with the argument of a function.
shopList = {
create: function createList(listName) {
listName = {};
listName["Banana"] = 2
},
output: function output(listName) {
console.log(listName)
},
};
shopList.create('list')
shopList.output('list')
When I run shopList.output 'list' is returned. How do I access the object over the argument? Hope this isn't a duplicate, been googling for hours now and didn't make any progress.