Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

How to find names by id

$
0
0

Find Names by idsi have two arrays want to find names by their ids.

person: [  {id: 1, name: 'abc'},  {id: 2, name: 'xyz'},  {id: 3, name: 'pqr'},  ]data: [  {id: 1, personId: [1,2,3]},  {id: 2, personId: [1,3]},  {id: 3, personId: [1,2]},]

Expected Output:

personId: [1,2,3] return // abc,xyz,pqrpersonId: [1,3] return // abc,pqrpersonId: [1,2] return // abc,xyz

I am using react-native.

I have tried this:

for (let person of this.state.data) {  for (let personName of person['personId']){    let name = this.state.person.find(nme => nme['id'] === personName);    alert(name);  }  }

Any help would be greatly appreciated


Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>