We want you to write a function, organizeitems, that organizes items by category. the argument to the function is an array of item objects. each item object has 3 properties, category (string), itemname (string), and onsale (boolean). here's an example:
var itemdata = [
{ category: 'fruit', itemname: 'apple', onsale: false },
{ category: 'canned', itemname: 'beans', onsale: false },
{ category: 'canned', itemname: 'corn', onsale: true },
{ category: 'frozen', itemname: 'pizza', onsale: false },
{ category: 'fruit', itemname: 'melon', onsale: true },
{ category: 'canned', itemname: 'soup', onsale: false },
];
the return value should be an object with category properties. each property value is an array of items that belong to that category.
here's an example return object based on our example input:
{
fruit: ['apple', 'melon($)'],
canned: ['beans', 'corn($)', 'soup'],
frozen: ['pizza']
};
note that items having onsale set to true should have '($)' appended to their item name.