Kontext
Summarize the products
Imagine that you sell 3 species of electronic equipment. Smartphones, laptops and air coolers.
An array that is called sales, holds the information about which kind has been solved. You hold there from the beginning the last 10 sales. ex:
let sales = ['smartphone', 'smartphone', 'laptop', 'smartphone', 'laptop', 'air cooler', 'smartphone', 'smartphone', 'laptop', 'smartphone'];
This array shows that have been solved until now 6 smartphones, 3 laptops and 1 air cooler.
Create a function that accepts an array of sold items (like sales) and returns an object with keys the string of the item ('smartphone', 'laptop', 'air cooler' etc) and a property the number of sold from this material.
For example. the function showQuantity(sales) is going to give back
// {
smartphone: 6,
laptop: 3,
air cooler: 1
}
Make this the most re-usable way you can.
You may want to remind yourself both ways for adding properties into an object. Especially one of those is going to untie your hands.