Loop through an array consisting of numbers and strings, but return sum of only numbers ActionScript -
this should pretty basic, there aren't many tutorials actionscript out there. javascript close, can't find how either. want able have mixed array consisting of string , number data types, loop through array , sum of numbers while ignoring strings.
example array:
var myarray:array = [13, 10, "blah", 5, "eh", 10, "twenty", "thirty"];
something following should trick:
var total:number = 0.0; (var i:int=0; i<myarray.length; i++) { if(myarray[i] number) total += myarray[i]; } trace(total);
Comments
Post a Comment