# Delete array values, how?

**URL:** <https://forum.kirupa.com/t/delete-array-values-how/161831>\
**Category:** Uncategorized\
**Created:** [September 7, 2005, 2:25pm UTC](https://forum.kirupa.com/t/delete-array-values-how/161831 "2005-09-07T14:25:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![2nd\_day](https://avatars.discourse-cdn.com/v4/letter/2/a4c791/32.png) [@2nd\_day](https://forum.kirupa.com/u/2nd_day)\
**Post date:** [September 7, 2005, 2:25pm UTC](https://forum.kirupa.com/t/delete-array-values-how/161831/1 "2005-09-07T14:25:25Z")

</div>

hi folks,

ive got a little problem…

lets say i have an array called numbers with these values: 0,1,2,3,4,5,6,7,8,9,10  
i want to call a random number of that array, something like this:

```auto
 rand = Math.round(Math.random()*(_root.numbers.length-1));
 no = numbers[rand];

```

then when ive got my value (no) i want to delete it from the array… and thats the problem… i tried to convert the array to a string and then slice it up… but because the ‘10’ has 2 characters it all goes wrong… this is the code i’ve got sofar and i would really appreciate it if you can help me further…

```auto
numbers = 11;
answers = new Array();
for (i=0; i<11; i++) {
 answers.push(i);
}
Array.prototype.shuffle = function() {
 this.sort(function () {
  return random(2);
 });
};
answers.shuffle();
function bla() {
 rand = Math.round(Math.random()*(_root.answers.length-1));
 no = answers[rand];
 str = answers.toString();
 pos = str.indexOf(no);
 begin = str.slice(0, pos);
 end = str.slice(pos+2);
 newstr = begin.concat("", end);
 if (answers.length<1) {
  trace("that's it");
 }
 trace(begin + " -- " + no + " -- "+ end);
 answers = newstr.split(",");
}

```
