Hong-Phuc Bui
2024-10-16 f8613c9ce2bd4b74b11727d2eae204f49151bcba
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const BigBag = {
    _weight: 0,
    _capacity: 0,
    _item : [],
    set capacity (cap)  {
        this._capacity = cap;
    } ,
 
    get items () {
        return [...this._item];
    },
 
    insertItem (item, weight) {
        this._item.push( {item, weight})
    }
};
 
 
BigBag.capacity = 30;
BigBag.insertItem("Blabla", 10);
 
let items = BigBag.items;
console.log(items);