I have two arrays in my program, one contains a list of strings that act as keys, the other contains objects that contain a key as well.
let classKeys = ['math', 'robotics'];
let classesInList = [{key : WIHUGDYVWJ, className : 'math'},{key : qwljdhkuqwdnqwdk, className : 'english'},{key : likubqwd, className : 'robotics'},];
I need to return another array that contains objects like classesInList only if the key (as the className property) exists in classKeys
For example, in this scenario, I would need to check the classKeys against the classesInList and create an array with two items :
[{key : WIHUGDYVWJ, className : 'math'},{key : likubqwd, className : 'robotics'}]
since english is not in the classKeys, it is deleted from the classesInList.
How would I go about this?
Side Note: I am using react native so I have access to es6 properties and functions.
I am completely stuck in this sense. No matter how simple this seems to be I just cannot find an answer.