I'm working with an array that looks like this
var items = [];
items.push({
name: "milk",
id: "832480324"
});
items.push({
name: "milk",
id: "6234312"
});
items.push({
name: "potato",
id: "983213"
});
items.push({
name: "milk",
id: "131235213"
});
Now I have created a function called order(name, amount)
. If I were to use it as follows: order(milk, 2)
, the function should return 2 ID's
for milk in the items array. What would be the best approach to achieve this task? (Creating a new question was necessary!)