I have an array filled with fridge items. I am trying to find the index of particular items and then splice them out of the array and then return the item and console.log the remaining items in the fridge. I have no clue why it isn't working. I have tried several different variations and I have tried looking at other similar answers for this question. Any advice or help is much appreciated.
fridge = ["milk", "cheese", "butter"];
function removeItemFromFridge(item) {
if (item.indexOf()) {
fridge.splice(item);
return item;
} else {
return null;
}
}
removeItemFromFridge("milk");
removeItemFromFridge("butter");
console.log(fridge);