Let's imagine I have this :
var fruits = [{ "Banana" : "yellow", "lemon" : "yellow"}, {"Orange" : "orange", "Mango" : "orange"}, {"Apple" : "red", "strawberry" : "red"}];
fruits.push({"Kiwi" : "green", "Green Apple" : "green", "watermelon" : "green" });
console.log(fruits);
Now I have an Array "fruits", with objects inside, and I'm using "push()" method to add new objects.
If I would like to add a new yellow fruit, like "Jamaican Banana : yellow" inside the yellow things object, how could I do that ?
{"Banana": "yellow", "lemon": "yellow"}… why store them like that? It’s the least useful structure.{"yellow": ["Banana", "lemon"], "orange": …}"would make a lot more sense.