I am working with an array called orders
.
orders = [
{table_id: 3, food_id: 5},
{table_id: 4, food_id: 2},
{table_id: 1, food_id: 6},
{table_id: 3, food_id: 4},
{table_id: 4, food_id: 6},
];
I am looking to create a function that can calculate the number of unique table_ids and food_ids in this array. For example,
For instance,
The unique table_ids in the list are1, 3, 4
totaling3
.
The unique food_ids in the list are2, 4, 5, 6
totaling4
Can anyone guide me on how to accomplish this task?