Copy link to clipboard
Copied
I have an array of 13 items (all of which are letters EX e,e,e,e ...). It is being read in from a database. However, I want to loop through the array and clean out any spaces that it might have. I am having trouble doing this. Anyone done this before?
Here is what I have so far.
outputBox.autoSize = TextFieldAutoSize.LEFT;
displayArray(system.selectedAnswers.length);
function displayArray(n:int):void {
for (var i:int = 0; i < n; i++)
{
system.selectedAnswers.replace(/^\s+|\s+$/g, "");
outputBox.appendText(String(system.selectedAnswers) + ",");
}
}
Thanks.
use a reverse for-loop:
function stripArrayF(a:Array):void{
for(var i:int=a.length-1;i>=0;i--){
a=a.split(' ').join('');
if(a.length==0){
a.splice(i,1);
}
}
}
Copy link to clipboard
Copied
use a reverse for-loop:
function stripArrayF(a:Array):void{
for(var i:int=a.length-1;i>=0;i--){
a=a.split(' ').join('');
if(a.length==0){
a.splice(i,1);
}
}
}
Copy link to clipboard
Copied
Thanks KGLAD
Copy link to clipboard
Copied
you're welcome.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now