my Goal is to be able to create a function that you can give a string as an argument, and be able to make an array that I could add Items to. You can see my attempt here, but it doesn't seem to work. aka, if I want to make a list name GroceryList, it returns GroceryList, but when I want to add an item to it, it says GroceryList is not defined.
function removeInstance(list, item){
for(var i = 0; i < list.length; i++){
if(item === list[i]){
list.splice(i, 1);
console.log(list);
break;
}
}
}
function makeList(name){
name = [];
console.log(name);
return name;
}
function removeAllItems(list, item){
for(var i = 0; i < list.length; i++){
if(item === list[i]){
list.splice(i, 1);
i--;
}
}
console.log(list);
}
function addItem(list, item){
list.push(item);
console.log(list);
}
any help would be awesome. Thanks!