subject

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.

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 20:10
Assume the existence of a bankaccount class. define a derived class, savingsaccount that contains two instance variables: the first a double, named interestrate, and the second an integer named interesttype. the value of the interesttype variable can be 1 for simple interest and 2 for compound interest. there is also a constructor that accepts two parameters: a double that is used to initialize the interestrate variable, and a string that you may assume will contain either "simple", or "compound", and which should be used to initialize the interesttype variable appropriately. there should also be a pair of functions getinterestrate and getinteresttype that return the values of the corresponding data members (as double and int respectively).
Answers: 2
question
Computers and Technology, 22.06.2019 21:30
Im doing this last minute and literally none of my neighbors or people that my dad works with use excel so if anyone could me make up an example
Answers: 1
question
Computers and Technology, 23.06.2019 07:10
If you want to import a picture into a dtp application, what must you do first? draw an image frame. import text. open the folder containing the file. select get image… from the windows menu.
Answers: 2
question
Computers and Technology, 24.06.2019 10:00
3. what do the terms multipotentialite, polymath, or scanner mean?
Answers: 2
You know the right answer?
We want you to write a function, organizeItems, that organizes items by category. The argument to th...
Questions