Hong-Phuc Bui
2025-01-16 2889de7f0c2d587a17fbd322af57c29e84238620
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);