I'm having trouble filtering my array using a filter function. I need to get an updated, filtered array. If there is a way to improve the code, please advise on what changes can be made.
class Store {
constructor(items) {
this._items = items;
}
getItems() {
return this._items;
}
addItem(item) {
this._items.push(item);
return this._items;
}
removeItem(item) {
this._items = this._items.filter(value => value != item);
return this._items;
}
}
let storage = new Store([
'Cubbage',
'Garlice',
'Sauce',
'Tomato',
]);
let items = storage.getItems();
console.table(items);
storage.addItem('banana');
console.table(items);
storage.removeItem('Tomato');
console.table(items); //