It's my first post here :-)
Please, Can you a advice on this:
I have an object and an Array:
activeItems = {
itemId: ["itemid1", "itemid2", "itemid3", "itemid4", "itemid5", "itemid6", "itemid7", "itemid8", "itemid9", "itemid10"],
price: ["10.50", "22.10", "13.40", "11", "1100", "500", "100", "400", "500", "20"]
};
selectItems = ["itemid3", "itemid8", "itemid9"];
In the activeItems object price[0]
represents the price for itemId[0]
.
All the prices are in correct order to represent prices for all item ids.
Now, I would like to create a new object with prices for the selecteItems
array.
It should look like this:
newObject = {
itemId: ["itemid3","itemid8","itemid9"],
price: ["13.40", "400", "500"]
};
Basically, I'm looking for a formula that creates new object for selectedItems
out of activeItems
and adds prices arrays for them.
Thank you in advance!