I hesitate to call it elegant but this function builds up the expression and then evals it,
It expects the variables to arrive as an object with keys "a", "b", etc.
Testing has been limited to the two inject strings and one flow variable shown!
Edit: simplified code
[{"id":"19154000c821042e","type":"inject","z":"7124eaac06216d5b","name":"flow.useb = true","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":160,"y":40,"wires":[["89606ab29439ffea"]]},{"id":"e1b39d51c46e251f","type":"inject","z":"7124eaac06216d5b","name":"flow.useb = false","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":160,"y":80,"wires":[["89606ab29439ffea"]]},{"id":"89606ab29439ffea","type":"change","z":"7124eaac06216d5b","name":"","rules":[{"t":"set","p":"useb","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":390,"y":60,"wires":[[]]},{"id":"52ad7e216485bdc4","type":"function","z":"7124eaac06216d5b","name":"JiggeryPokery","func":"const reference = { // ALL possible variables\n \"a\": { \"testvalue\": 2, \"operator\": \">\", \"flowVar\":\"usea\"},\n \"b\": { \"testvalue\": 7, \"operator\": \">\", \"flowVar\":\"useb\"},\n \"c\": { \"testvalue\": 5, \"operator\": \"<\", \"flowVar\":\"usec\"},\n \"d\": { \"testvalue\": 19, \"operator\": \"<\", \"flowVar\": \"duntexist\" }, // flowVar need not exist\n }\nlet cmd = \"(\"\nfor (const key in reference) {\n if (msg.payload.hasOwnProperty(key)) {\n const usethisproperty = flow.get(reference[key].flowVar) ?? true \n if (usethisproperty) { \n cmd += msg.payload[key] + reference[key].operator + reference[key].testvalue + \" && \"\n } \n }\n}\ncmd += ' 1==1)'\nnode.warn(cmd)\nlet result = eval(cmd)\nnode.warn(result)","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":400,"y":200,"wires":[[]]},{"id":"21f8da981884b87e","type":"inject","z":"7124eaac06216d5b","name":"{\"a\": 3, \"b\": 8, \"c\": 4}","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"a\": 3, \"b\": 8, \"c\": 4}","payloadType":"json","x":150,"y":200,"wires":[["52ad7e216485bdc4"]]},{"id":"94ba0372e2937a84","type":"inject","z":"7124eaac06216d5b","name":"{\"a\": 3, \"b\": 6, \"c\": 4}","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"a\": 3, \"b\": 6, \"c\": 4}","payloadType":"json","x":150,"y":240,"wires":[["52ad7e216485bdc4"]]}]