Skip to content
Advertisement

How to compare a string with a value of an object in an array

I want to check if a string matches another string in an array of objects.

Here’s my code

JavaScript

Advertisement

Answer

Since you’re clearly already using ES6, the most idiomatic way is using Array.includes after mapping the array:

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