# 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:** 1\
**Showing post:** 4

<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!

---

_[View the full topic](https://community.glideapps.com/t/most-occurring-value-in-an-array/53286)._
