# \[MX\]Duplicate Array Item Checker

**URL:** <https://forum.kirupa.com/t/mx-duplicate-array-item-checker/43314>\
**Category:** flash\
**Created:** [February 20, 2004, 10:59pm UTC](https://forum.kirupa.com/t/mx-duplicate-array-item-checker/43314 "2004-02-20T22:59:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![foochuck](https://avatars.discourse-cdn.com/v4/letter/f/dfb087/32.png) [@foochuck](https://forum.kirupa.com/u/foochuck)\
**Post date:** [February 20, 2004, 10:59pm UTC](https://forum.kirupa.com/t/mx-duplicate-array-item-checker/43314/1 "2004-02-20T22:59:31Z")

</div>

hello :hair:

I’m wondering if someone could check my code below and let me know if they see any probs. I’ve basically made up a function that checks to see if any 2 or more items in an array are the same. If there are duplicate items the funtion is supposed to add 1 to a variable and push that variable into another array. That other array then shifts the numbers inside of it into another array on the tailend of the duplicate array items so they are unique. Heres what it looks like:

Heres my function:

```auto

Array.prototype.dupCount = function(countElement) {
	tempCount = 0;
		for (i=0; i<this.length; i++) {
			trace(this*);
			if (countElement == this*) {
				tempCount++;
				catCountAry.push(tempCount);
			}
		}
};

```

Heres the loop that calls the function:

```auto

		for (var elem in subCatsAry) {
			subCatsAry.dupCount(subCatsAry[elem]);
				if (catCountAry.length == 0) {
					subCatsAry[elem] += 1;
					catCountAry.shift()
				} else {
					for (i=0; i<=catCountAry.length; i++) {
						subCatsAry[elem] += catCountAry.shift();
					}
				}
		}

```

Any ideas? :sen:

Thanks :cyborg:
