# For each loop confusion

**URL:** https://community.thunkable.com/t/for-each-loop-confusion/3275402
**Category:** Questions about Thunkable X
**Tags:** help
**Created:** [October 16, 2024, 7:48am UTC](https://community.thunkable.com/t/for-each-loop-confusion/3275402 "2024-10-16T07:48:41Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![s.v.naguine18jsb3](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@s.v.naguine18jsb3](https://community.thunkable.com/u/s.v.naguine18jsb3)
#### Post date: [October 16, 2024, 7:48am UTC](https://community.thunkable.com/t/for-each-loop-confusion/3275402/1 "2024-10-16T07:48:41Z")

</div>

I get a list and then I loop through each item of the list. The item(j) contails the email and role in the following format: email/role. I can’t seem to find a way to extract the email from j so i can compare for equality and get the role as well so i can return it. The snippet shows how far i have come:

 ![Screenshot 2024-10-16 094824](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/4/5/4597ff07c0d04426a1180f7c41d23a7ad3ba209b.png)

---

<div class="post-metadata">

### Author: ![s.v.naguine18jsb3](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@s.v.naguine18jsb3](https://community.thunkable.com/u/s.v.naguine18jsb3)
#### Post date: [October 16, 2024, 9:32am UTC](https://community.thunkable.com/t/for-each-loop-confusion/3275402/2 "2024-10-16T09:32:40Z")

</div>

![Screenshot 2024-10-16 112907](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/f/f/ffe599cdc0c786fc80959c5d2c2d5fcc780ff5f5.png)  
I have the following block. I don’t understand what I did wrong that causes the function return value to be undefined.

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [October 16, 2024, 2:47pm UTC](https://community.thunkable.com/t/for-each-loop-confusion/3275402/3 "2024-10-16T14:47:03Z")

</div>

You need to provide an example of the data you’re using. Without that, we have no way of knowing if your blocks are correct.

---

<div class="post-metadata">

### Author: ![s.v.naguine18jsb3](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@s.v.naguine18jsb3](https://community.thunkable.com/u/s.v.naguine18jsb3)
#### Post date: [October 16, 2024, 3:01pm UTC](https://community.thunkable.com/t/for-each-loop-confusion/3275402/4 "2024-10-16T15:01:11Z")

</div>

I ask the user for the email and roles when they sign up. Afterwhich, i concatinate them with a slash in between using the join. It works as expected until here. Later on, I go into adding the concatinated string to the list which doesn’t work. I will attach the block where i did those operations. Thank you for your help.

 ![Screenshot 2024-10-16 165805](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/e/1/e183dd6bf860fb2eeeed00d580178b5bffce3686.png)

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [October 17, 2024, 2:38am UTC](https://community.thunkable.com/t/for-each-loop-confusion/3275402/5 "2024-10-17T02:38:11Z")

</div>

Okay, I was hoping for a visual but since you didn’t provide that I’m going to assume that you mean the date looks something like this:

[bob@gmail.com](mailto:bob@gmail.com)/teacher  
[mary@gmail.com](mailto:mary@gmail.com)/doctor  
[angela@gmail.com](mailto:angela@gmail.com)/firefighter

Why are you storing them that way? **It would be better to store them in separate keys in Firebase.**

But if you must do it that way, those parsing blocks are going to provide a result. You’re storing those results in variables. What happens when you display them in labels? I wonder if you’re going to get “[bob@gmail.com](mailto:bob@gmail.com)/” instead of what you’re expecting which is “[bob@gmail.com](mailto:bob@gmail.com)”.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/f/0f59f292712368bce16ff80133ae10de8a6f27e8.png) [@system](https://community.thunkable.com/u/system)
#### Post date: [January 15, 2025, 2:38am UTC](https://community.thunkable.com/t/for-each-loop-confusion/3275402/6 "2025-01-15T02:38:19Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
