var arr:Array = [8,11,13,24,19,8,4,6,5];

var maxValue:Number = Math.max.apply(null, arr);
var minValue:Number = Math.min.apply(null, arr);



--- In flexcoders@yahoogroups.com, "Tracy Spratt" <tspr...@...> wrote:
>
> Be aware that if you have two loops in a function and use this syntax, you
> will get a duplicate variable definition warning.
> 
>  
> 
> Tracy Spratt,
> 
> Lariat Services, development services available
> 
>   _____  
> 
> From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On
> Behalf Of - -
> Sent: Thursday, April 16, 2009 1:39 PM
> To: flexcoders@yahoogroups.com
> Subject: Re: [flexcoders] How can I receive the smallest value within an
> Array?
> 
>  
> 
> 
> 
> 
> 
> 
> Thanks Paul!
> 
>  
> 
>   _____  
> 
> From: Paul Andrews <p...@...>
> To: flexcoders@yahoogroups.com
> Sent: Thursday, April 16, 2009 12:44:18 PM
> Subject: Re: [flexcoders] How can I receive the smallest value within an
> Array?
> 
> Just for the future, most people would do this:
> 
>  
> 
> for ( var i:int =1; i<array.length; i++)
> 
>  
> 
> ----- Original Message ----- 
> 
> From: - - <mailto:sailorse...@...>  
> 
> To: flexcod...@yahoogro <mailto:flexcoders@yahoogroups.com>  ups.com 
> 
> Sent: Thursday, April 16, 2009 5:06 PM
> 
> Subject: Re: [flexcoders] How can I receive the smallest value within an
> Array?
> 
>  
> 
> I got it:
> 
>  
> 
> public function maxValue(array: Array):int
> 
> {
> 
> var value:int = array[0];
> 
> var i:int = new int(0);
> 
> for (i; i<array.length; i++) 
> 
> { 
> 
> if (array[i]>value)
> 
> { 
> 
> value = array[i]; 
> 
> } 
> 
> } 
> 
> return value;
> 
> }
> 
> public function minValue(array: Array):int
> 
> {
> 
> var value:int = array[0];
> 
> var i:int = new int(0);
> 
> for (i; i<array.length; i++) 
> 
> { 
> 
> if (array[i]<value)
> 
> { 
> 
> value = array[i]; 
> 
> } 
> 
> } 
> 
> return value;
> 
> }
> 
>  
> 
>  
> 
> 
>   _____  
> 
> 
> From: sailorsea21 <sailorsea21@ yahoo.com <http://yahoo.com/> >
> To: flexcod...@yahoogro ups.com <http://ups.com/> 
> Sent: Thursday, April 16, 2009 11:56:01 AM
> Subject: [flexcoders] How can I receive the smallest value within an Array?
> 
> Hi everyone, if I have an array as
> 
> var boxSize:Array = new Array(25, 45, 32, 70, 50, 46, 80, 10);
> 
> Is there a function that will return me the smallest value within that
> array?
> 
> Thanks.
> 
> -David
>


Reply via email to