Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function vehicleProduction(arr) {
- class VehicleFactory {
- manufacturers = {};
- addRecord = ([man, mod, qty]) => ((this.manufacturers[man] ||= {})[mod] = (this.manufacturers[man][mod] || 0) + +qty);
- showRecords = () => Object.entries(this.manufacturers).forEach(([man, mods]) => {
- console.log(man);
- Object.entries(mods).forEach(([mod, qty]) => console.log(`###${mod} -> ${qty}`));
- });
- }
- const factory = new VehicleFactory();
- arr.forEach(e => factory.addRecord(e.split(' | ')));
- factory.showRecords();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement