I have the following array:
array = ["ProgA", "ProgC", "ProgG"]
This array can change depending on the user input.
I have the following Json File:
{"ABC":{
"ProgA": 1,
"ProgB": 0,
"ProgC": 1,
"ProgD": 0,
"ProgE": 0,
"ProgF": 1,
"ProgG": 1,
"ProgH": 0
},
"DEF":{
"ProgA": 1,
"ProgB": 0,
"ProgC": 0,
"ProgD": 0,
"ProgE": 1,
"ProgF": 0,
"ProgG": 1,
"ProgH": 0
},
"GHI":{
"ProgA": 1,
"ProgB": 1,
"ProgC": 1,
"ProgD": 1,
"ProgE": 1,
"ProgF": 1,
"ProgG": 1,
"ProgH": 1
},
"JKL":{
"ProgA": 1,
"ProgB": 0,
"ProgC": 1,
"ProgD": 1,
"ProgE": 0,
"ProgF": 1,
"ProgG": 0,
"ProgH": 1
},
"MNO":{
"ProgA": 1,
"ProgB": 1,
"ProgC": 1,
"ProgD": 0,
"ProgE": 1,
"ProgF": 1,
"ProgG": 1,
"ProgH": 1
}}
My goal is to basically return all the names ("ABC", "DEF" etc) which have the ProgA, ProgC and ProgG == 1
I am not sure how to evaluate the if statements when the conditions are in an array which can change.
console.log(obj.ABC[ array[1] ])will show the value of the"ProgC"switch insideABC(objis the variable name of he json object)