Skip to content
Advertisement

How to simply find matching values in [[], [], []] arrays in javascript

new to javascript. i have these two arrays

JavaScript

how can i find the matching values?

tried below but returns empty array probably because it’s for normal array structure [”, ”, ”]

JavaScript

Matching value should be [‘2’]

Advertisement

Answer

You can simply use .flat() to flatten the arrays so you only deal with the values like so :-

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