I am new to javascript so I am struggling to even know where to start. Please can someone help me.
I have this list of ingredients:
const Ingris = [
{
val: "onion,",
amount: "1",
},
{
val: "paprika",
amount: "½ tsp",
},
{
val: "yogurt",
amount: "1/2 Cup",
},
{
val: "fine sea salt",
amount: "½ tsp ",
},
];
I want to categories them based on these variables below:
var spices = ["paprika", "parsley", "peppermint", "poppy seed", "rosemary"];
var meats = ["steak", "ground beef", "stewing beef", "roast beef", "ribs"];
var dairy = ["milk", "eggs", "cheese", "yogurt"];
var produce = ["peppers", "radishes", "onions", "tomatoes"];
This is what I am trying to obtain:
// desired output:
const ShoppingList = [
{
produceOutput: [
{
val: "garlic, minced",
amount: "8 cloves ",
},
],
spicesOutput: [
{
val: "paprika",
amount: "½ tsp ",
},
{
val: "onion",
amount: "1",
},
],
NoCategoryOutput: [
{
val: "fine sea salt",
amount: "½ tsp",
},
],
},
];