I have tried a lot but couldn't figure it out.
response = JSON.parse(this.responseText).user.filter(element => element.list == "State-CM" || element.list == "Ministers-Ministries")
In the above code, I am filtering a Json response based on a fixed set of string values hard coded in the condition (element.list == "State-CM" || element.list == "Ministers-Ministries"
). and it is working.
But I want to filter the Json based on a dynamic array (topics
) which can change from time to time. Whatever values are there in the array, only those should be the filter criteria.
const topics = ["State-CM", "Ministers-Ministries","etc.","",.....];