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