# Need help with array

**URL:** <https://forum.kirupa.com/t/need-help-with-array/182429>\
**Category:** Uncategorized\
**Created:** [March 18, 2006, 5:11am UTC](https://forum.kirupa.com/t/need-help-with-array/182429 "2006-03-18T05:11:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pixeldude](https://avatars.discourse-cdn.com/v4/letter/p/57b2e6/32.png) [@pixeldude](https://forum.kirupa.com/u/pixeldude)\
**Post date:** [March 18, 2006, 5:11am UTC](https://forum.kirupa.com/t/need-help-with-array/182429/1 "2006-03-18T05:11:18Z")

</div>

Hi…

Ok what I after is how to “+” 1 for duplicate elements in array …let’s say I just push the value in array like this…

```auto

someArr = [one,two,three,four];

```

so next time I want to push the same name elements eg; “one”…so how to make so that the code can check for any existing file name then it found the duplicate name it will plus “1” to make it different…so the final value in array will be like this…

```auto

someArr = [one,two,three,four,one1];

```

so next time the code will stil check for duplicate name…maybe I wil have the value in array liek this…

```auto

someArr = [one,two,three,four,one1,one2,two1,three1];

```

it is because later on i want to remove some value from this array…so far what I have is it not checking for duplicate…so when I’m delete soem value in array it will delete all the same name…eventhough I want to delete one elements only…here;s what I have so far

```auto

stop();
//define empty array
var myArray = [];

//push value into array
addbtn.onPress = function(){
    myArray.push(input_txt.text);
    input_txt.text = "";
    output_txt.text = myArray;
}
//delete value in array

delbtn.onPress = function(){
    for(var i = 0;i<myArray.length;i++){
        if(input_txt2.text == myArray*){
            myArray = myArray.remove(myArray*);
            output_txt2.text = myArray;
            break;
        }
    }
}

Array.prototype.remove = function(obj) {
  var a = [];
  for (var i=0; i<this.length; i++) {
    if (this* != obj) {
      a.push(this*);
    }
  }
  return a;
}

```

u can try it here…

[http://fifin04.propertyaccess.com.my/array/arrayquestion.html](http://fifin04.propertyaccess.com.my/array/arrayquestion.html)

the fla’s

[http://fifin04.propertyaccess.com.my/array/arrayquestion.zip](http://fifin04.propertyaccess.com.my/array/arrayquestion.zip)

I’m really need help with it…any help would be appreciate…

tq

---

<div class="post-metadata">

**Author:** ![pixeldude](https://avatars.discourse-cdn.com/v4/letter/p/57b2e6/32.png) [@pixeldude](https://forum.kirupa.com/u/pixeldude)\
**Post date:** [March 18, 2006, 10:32pm UTC](https://forum.kirupa.com/t/need-help-with-array/182429/2 "2006-03-18T22:32:27Z")

</div>

thanks for the reply guys…Macaroni Ted and Stringy…

nice code there…it works like a charm now…

thanks again…🍺
