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

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -