Ciao ragazzi,
una domanda:
ho un array di 9 elementi, tra i quali faccio un random;
io devo eliminare da questo array gli elementi che sono già stati pescati dal random.
Come faccio?
Grazie!
![]()
Ciao ragazzi,
una domanda:
ho un array di 9 elementi, tra i quali faccio un random;
io devo eliminare da questo array gli elementi che sono già stati pescati dal random.
Come faccio?
Grazie!
![]()
codice:Array.prototype.remove = function(rem) { // [ andr3a ] // Simple prototype to // remove an element from // a normal or multidimension Array for(var i=0; i<this.length; i++) { if(this[i]==rem) { this.splice(i,1); } else if(this[i].length > 0) { this[i].remove(rem); } } return this; } // Example: var mioArray = new Array("uno", "due", "tre"); trace( mioArray.join( " - " ) ); mioArray.remove( "due" ); trace( mioArray.join( " - " ) );