I am making my first project as a food rota that gives out a shopping list from the chosen Recipe ingredients.
I managed to write the loop
that would combine all the ingredients in one array
where it takes us to my question.
I would like to combine the same ingredients in the array ie: [1kg Carrots, 1kg Spinach, 1kg Carrots]
, I would like it to combine the repeating (1kg Carrots, 1kg Carrots)
into (2kg Carrots)
Is there a way to do this?
Sorry if my request is sloppy, first time asking a question.
I could work it so that it would cancel out the similar ones as the outcome of [1kg Carrots, 1kg Carrots]
would be [1kg Carrot]
.
Unfortunately I am at work at the moment and do not have access - will update if needed.