I have a collection of unlimited volume (maybe 0, maybe 1000, maybe a million). I need to look for the attributes of each model in the collection and return the attributes (and their values) that are the same.
For example, if I have three models in my collection:
modelOne:
color: "red"
age: 10
size: "large"
modelTwo:
color: "red"
age: 11
size: "medium"
modelThree:
color: "red"
age: 9
size: "large"
I need an application to return color: "red"(or another derivation that can be parsed), since it is the only attribute equal to all three models.
Edit John Munsch's solution worked very well, but now the requirements have changed since some attributes can now be arrays. Is there a way to compare regular attributes and attributes that are arrays?
New code example:
modelOne:
color: "red"
age: 10
sizes: ["small", "large"]
modelTwo:
color: "red"
age: 9
sizes: ["small", "large"]