June 13, 2017
enum
is a reserved keyword so you should not use such reserved keywords.
Find a working example of your code below:
var t_enum = {
aitem: {
Desc: 'A description',
Value: 0,
Group: 'A'
},
bitem: {
Desc: 'b description',
Value: 1,
Group: 'B'
},
bitem: {
Desc: 'c description',
Value: 2,
Group: 'C'
}
}
var neededGroup = 'A';
var neededValues = [];
Object.keys(t_enum).forEach(function (x) {
var item = t_enum[x];
if (item.Group == neededGroup){
neededValues.push(item.Value);
return;
}
})
console.log(neededValues);
Its an alternate approach from what Toddo is suggesting.