var tempStoreFood = [];
var sameFoodID = [];
var differentFoodID = [];
var finalStoreFood = [];
console.log("Temporary stored food", tempStoreFood);
console.log("Same Food Group", sameFoodID);
console.log("Different Food Group", differentFoodID);
console.log("Concatenate");
for (i = 0; i < self.foods.length; i++) {
var foodBrand = self.foods[i];
var foodBrandID = self.foods[i].brand_id;
tempStoreFood.push(foodBrand);
for (j = 0; j < tempStoreFood.length; j++) {
var foodID = tempStoreFood[j].brand_id;
var singleFood = tempStoreFood[j];
if (foodID == foodBrandID) {
sameFoodID.push(singleFood);
break;
}
if (foodID !== foodBrandID) {
differentFoodID.push(singleFood);
break;
}
}
from the output i have got the samefoodID array and different food id array. now i want to group it as this(final output). any idea how can i do this using javascript.