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