# Most occurring value in an array

**URL:** <https://community.glideapps.com/t/most-occurring-value-in-an-array/53286>\
**Category:** Ask for Help\
**Created:** [November 4, 2022, 3:12am UTC](https://community.glideapps.com/t/most-occurring-value-in-an-array/53286 "2022-11-04T03:12:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![james](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/james/32/71213_2.png) [@james](https://community.glideapps.com/u/james)\
**Post date:** [November 4, 2022, 3:12am UTC](https://community.glideapps.com/t/most-occurring-value-in-an-array/53286/1 "2022-11-04T03:12:10Z")

</div>

Any ideas on a way of returning the value in an array that occurs the most (ideally without getting super complicated)?

---

<div class="post-metadata">

**Author:** ![gvalero](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/gvalero/32/1037_2.png) [@gvalero](https://community.glideapps.com/u/gvalero)\
**Post date:** [November 4, 2022, 12:35pm UTC](https://community.glideapps.com/t/most-occurring-value-in-an-array/53286/2 "2022-11-04T12:35:23Z")

</div>

Hola!

Would you like a No-Code or a Low-Code solution? 😉

---

<div class="post-metadata">

**Author:** ![james](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/james/32/71213_2.png) [@james](https://community.glideapps.com/u/james)\
**Post date:** [November 4, 2022, 2:28pm UTC](https://community.glideapps.com/t/most-occurring-value-in-an-array/53286/3 "2022-11-04T14:28:50Z")

</div>

Hi 🙂

I am open to either, provided performance in Glide is fast and reliable.

---

<div class="post-metadata">

**Author:** ![gvalero](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/gvalero/32/1037_2.png) [@gvalero](https://community.glideapps.com/u/gvalero)\
**Post date:** [November 4, 2022, 4:24pm UTC](https://community.glideapps.com/t/most-occurring-value-in-an-array/53286/4 "2022-11-04T16:24:08Z")

</div>

Ok!  
We can start using this [trick](https://community.glideapps.com/t/count-duplicate-elements-in-an-array-or-list/) but changing a little the code.

And I think it can be what you were looking for… right?

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

```auto
const arr=p1.split(",");
let maxFrec=-1;
let maxItem

arr.forEach((item) => {
   x= arr.filter(function(value) {
       return value == item;
   }).length 
  
   if (x> maxFrec) {
      maxFrec=x;
      maxItem= item;
   }
})
return maxItem

```

As you can see in my code/example, I am not using an array of items already created. Instead, I use a list of items (almost the same) to work with it in my code and find what we are needing. We have to do this because of Glide’s JavaScript plugin doesn’t support an array as parameter so far. 🫤

I hope it helps you.

Saludos!
