# Looking Up Data from One Array to a Second Array

**URL:** https://discourse.nodered.org/t/looking-up-data-from-one-array-to-a-second-array/18696
**Category:** General
**Created:** [2 December 2019 15:48 UTC](https://discourse.nodered.org/t/looking-up-data-from-one-array-to-a-second-array/18696 "2019-12-02T15:48:21Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![CHR1ST00](https://avatars.discourse-cdn.com/v4/letter/c/b77776/32.png) [@CHR1ST00](https://discourse.nodered.org/u/CHR1ST00)
#### Post date: [2 December 2019 15:48 UTC](https://discourse.nodered.org/t/looking-up-data-from-one-array-to-a-second-array/18696/1 "2019-12-02T15:48:21Z")

</div>

Hello all, thank you for the great resource that this forum is.  
I am looking for some assistance in looking up variables.

For example, if I have an "Array1" that returns:

```auto
[
{"id":1,"name":"abc,"label_ids":1},
{"id":2,"name":"def","label_ids":2},
{"id":3,"name":"ghi","label_ids":3}
]

```

I can save these into something like global.lookup

Now if I have another Array2 from a different endpoint that returns:

```auto
{"id"1234,"label_ids":[1,2,3]}

```

How do I look up the name on the Array2 from the global.lookup  
Ideally I would like to convert all the label\_ids to each contain and array with "id" and "name"  
At the minimum I would like replace the "label\_ids" in Array2 with "name" from Array1 for the entire array.  
I could do it with If statements, but it is really messy especially if new labels get added.  
Thank you very much for your assistance.

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [2 December 2019 15:56 UTC](https://discourse.nodered.org/t/looking-up-data-from-one-array-to-a-second-array/18696/2 "2019-12-02T15:56:07Z")

</div>

Hi @CHR1ST00

before diving into code, could you provide an example of the output you'd like given the example inputs you've shared? Helps to avoid any misinterpretation of what you've written.

---

<div class="post-metadata">

### Author: ![CHR1ST00](https://avatars.discourse-cdn.com/v4/letter/c/b77776/32.png) [@CHR1ST00](https://discourse.nodered.org/u/CHR1ST00)
#### Post date: [3 December 2019 00:25 UTC](https://discourse.nodered.org/t/looking-up-data-from-one-array-to-a-second-array/18696/3 "2019-12-03T00:25:12Z")

</div>

Hello knolleary,

Thank you for your reply  
According to my example above  
Instead of :

```auto
{"id"1234,"label_ids":[1,2,3]}

```

I would like:

```auto
{"id"1234,"label_ids":
[
{"label_ids":"label_ids"},
{"label_ids":"name"}
]}

```

Not sure if I have explained that exceptionally well.
