Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function autoEngineeringCompany(arr) {
- const company = arr.reduce((acc, el) => {
- let [brand, model, count] = el.split(' | ');
- acc[brand] = acc[brand] || {};
- acc[brand][model] = (acc[brand][model] || 0) + Number(count);
- return acc;
- }, {});
- Object.entries(company).forEach(([brand, models]) => {
- console.log(brand);
- Object.entries(models).forEach(([model, count]) => console.log(`###${model} -> ${count}`));
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement