Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function autoEngineeringCompany(arr) {
- class AutoEngineeringCompany {
- constructor() {
- this.brands = {};
- }
- addProductionData = ([brand, model, count]) =>
- this.brands[brand] = { ...this.brands[brand], [model]: (this.brands[brand]?.[model] || 0) + Number(count) };
- displayProductionData = () =>
- Object.entries(this.brands).forEach(([brand, models]) => {
- console.log(brand);
- Object.entries(models).forEach(([model, count]) => console.log(`###${model} -> ${count}`));
- });
- }
- const company = new AutoEngineeringCompany();
- arr.map(e => e.split(' | ')).forEach(e => company.addProductionData(e));
- company.displayProductionData();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement