# Remove only 1 item from the Array

**URL:** https://community.glideapps.com/t/remove-only-1-item-from-the-array/65717
**Category:** Ask for Help
**Created:** [September 2, 2023, 2:01pm UTC](https://community.glideapps.com/t/remove-only-1-item-from-the-array/65717 "2023-09-02T14:01:21Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Trustin](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/trustin/32/88217_2.png) [@Trustin](https://community.glideapps.com/u/Trustin)
#### Post date: [September 2, 2023, 2:01pm UTC](https://community.glideapps.com/t/remove-only-1-item-from-the-array/65717/1 "2023-09-02T14:01:21Z")

</div>

I have an array column [Apple, Apricot, Apricot]. Below I am showing using joined list.  
The second column (Read Food to remove) are food i want to remove form the first column. I realise that using the unique elements computed column will instead remove both Apricot from the list.  
My desired output is to remove only 1 Apricot based on the (Food to remove) column.  
Any advice?

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/5/f/5faa20086fe1b14c6a04ca39d9779b785ea2baf9.png)

---

<div class="post-metadata">

### Author: ![Dilon\_Perera](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/dilon_perera/32/85652_2.png) [@Dilon\_Perera](https://community.glideapps.com/u/Dilon_Perera)
#### Post date: [September 2, 2023, 2:53pm UTC](https://community.glideapps.com/t/remove-only-1-item-from-the-array/65717/2 "2023-09-02T14:53:24Z")

</div>

Hi @Trustin,

Did I got you correctly?

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/8/8/882cbb258d536100080b342a08fba85aebaccda9.png)  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/1/e/1edefa6dda0f981e3a986119738bccc48eb7cd0b.png)  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/5/9/592623367891d329c12fe40447b045063e818505.png)

Also maybe with some js :

![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/3/f/3f9ee399a7031eea022a029d4055c3c18181dfc4.png)

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/0/8/08ca8cc2b22a1fc4dc84fee918398de39908f6c0.png)

```auto
function removeItemFromCSV(csvString, itemToRemove) {
  const values = csvString.split(',');
  let removed = false;

  const updatedValues = values.filter((value) => {
    if (value.trim() === itemToRemove && !removed) {
      removed = true;
      return false;
    }
    return true;
  });

  return updatedValues.join(', ').trim();
}

const csvString = p1;
const itemToRemove = p2;
const result = removeItemFromCSV(csvString, itemToRemove);

return result;

```

Thank you

---

<div class="post-metadata">

### Author: ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)
#### Post date: [September 2, 2023, 2:54pm UTC](https://community.glideapps.com/t/remove-only-1-item-from-the-array/65717/3 "2023-09-02T14:54:59Z")

</div>

Here is another JavaScript option that is slightly less verbose:

```auto
const arr = p1.split(', ');
const index = arr.indexOf(p2);
if (index != -1) {
  arr.splice(index,1);
  return arr.join(', ');
}
return p1;

```

 ![CleanShot 2023-09-02 at 22.53.15@2x](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/0/a/0a030410417f6553edec29fa3425216b4216c9c9.png)

---

<div class="post-metadata">

### Author: ![Trustin](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/trustin/32/88217_2.png) [@Trustin](https://community.glideapps.com/u/Trustin)
#### Post date: [September 2, 2023, 3:28pm UTC](https://community.glideapps.com/t/remove-only-1-item-from-the-array/65717/4 "2023-09-02T15:28:38Z")

</div>

Yes. Time to deploy some javascript! Thanks! #WelcometotheNocodecodingclub lol

---

<div class="post-metadata">

### Author: ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/system/32/53398_2.png) [@system](https://community.glideapps.com/u/system)
#### Post date: [September 9, 2023, 3:29pm UTC](https://community.glideapps.com/t/remove-only-1-item-from-the-array/65717/5 "2023-09-09T15:29:37Z")

</div>

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