Lulunga

class storage

Jun 28th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. class Storage {
  2. constructor(cap) {
  3. this.capacity = cap,
  4. this.storage = []
  5. this.totalCost = 0;
  6. this.addProduct = (p) => {
  7. let arr = p;
  8. this.capacity -= arr.quantity;
  9. this.totalCost += arr.price * arr.quantity;
  10. this.storage.push(p)
  11. }
  12. this.getProducts = () => {
  13. return this.storage.map(element => JSON.stringify(element)).join('\n');
  14. }
  15. }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment