Skip to content
Advertisement

Typescript data filtering on nested array based on another array

Im new to TS I have an array of data that looks like this

JavaScript

I want to loop over a the data in the “industries” in the AllJobs array and check if any of those vales match any of the values in desiredSkills. If no matching values, filter out that object. I don’t know if im doing this right at all.

Desired results:

JavaScript

Here is my previous code. That is currently not working.

JavaScript

I have also tried

JavaScript

Advertisement

Answer

You don’t really need TypeScript here, so here’s a JS solution for you:

JavaScript

Should be easy to translate to TS. Hope it helps!

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement