I am trying to compare these two nested arrays to ensure if they are the same but I couldn't figure it out, I tried to start but couldn't finish.
I need to make sure they have both the same food_names
and the same ingredients in the selected_ingredients
array.
Any help would be appreciated.
interface DataInterface {
food_name: string,
selected_ingredients: Array<string>
}
const orderFood: Array<DataInterface> = [
{selected_ingredients: ["Tomatoes", "Lettuce", "Cheese"], food_name: "Single Burger"},
{selected_ingredients: [], food_name: "Fountain Drink"}
];
const orderFood2: Array<DataInterface> = [
{food_name: "Single Burger", selected_ingredients: ["Tomatoes", "Lettuce", "Cheese"]},
{food_name: "Fountain Drink", selected_ingredients: []}
]
function isSame() {
for(let i = 0; i < orderFood.length; i++) {
}
return false;
}