I have an array which is like this:
var Data=[{
"Class":"item1","element":["a","b","c","d","e"],
"Class":"item2","element":["a","b","c","d","e"],
"Class":"item3","element":["a","b","c","d","e"],
"Class":"item4","element":["a","b","c","d","e"]
}];
I have two variables:
var class='item1';
var element='a';
I want a condition that if var class values match "item1" then var element value should be matched with its elements only like:
if (class == Data.Class) then element should be matched with Data.element near it
Any ideas?
Datavariable is wrong. How can you have same key/value pairs 4 times. Only the last one will be stored.Dataarray redefines"Class"and"element". Did you mean for each line to be a separate object in the array?