Skip to content
Advertisement

How to compare an array of objects with an array of strings?

How to compare these arrays? I want to compare and get a result like the below.

Array of string

JavaScript

Array of object

JavaScript

As you can see there is no Sliders categoryName in the array of string. I expected the result should be another array of objects. As the following

JavaScript

Thanks!

Advertisement

Answer

You can use .filter as follows:

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