Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Storage {
- constructor (capacity) {
- let arr = [];
- let cost = 0;
- this.addProduct = function (obj) {
- arr.push(JSON.stringify(obj));
- capacity -= obj.quantity;
- cost += obj.price * obj.quantity;
- this.capacity = capacity;
- this.totalCost = cost;
- }
- this.getProducts = function () {
- return arr.join('\n');
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement