# Finding Maximum-Minimum value in an array (by Kirupa)

**URL:** https://forum.kirupa.com/t/finding-maximum-minimum-value-in-an-array-by-kirupa/184278
**Category:** flash
**Created:** [April 3, 2006, 11:02pm UTC](https://forum.kirupa.com/t/finding-maximum-minimum-value-in-an-array-by-kirupa/184278 "2006-04-03T23:02:18Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![torquemada](https://avatars.discourse-cdn.com/v4/letter/t/a183cd/32.png) [@torquemada](https://forum.kirupa.com/u/torquemada)
#### Post date: [April 3, 2006, 11:02pm UTC](https://forum.kirupa.com/t/finding-maximum-minimum-value-in-an-array-by-kirupa/184278/1 "2006-04-03T23:02:18Z")

</div>

I’m using FlashMX, and my english isn’t quiet good but I hope someone will help me.  
I seek to take advantage of this good tutorial to extract the values  
minimum and maximum of a series of dates that an user can select  
pressing buttons in a calendar.

Each button of the calendar takes associate a variable that corresponds  
to the ordinal number starting from 1 up to 201 (e.g.dn1=1 until dn201=201).

The selected values are used to build an array declared this way  
myArray = new Array(dn1, dn2, dn3, dn4,…, dn201);  
Initially, before the user intervention, the values of all the variables  
(dn1, dn2, dn3, dn4,…, dn201) they have been  
declared as 0 (zero), so that the new array looks like (0, 0, 0, 0,…, 0).

When the user finishes the selection of dates is requested to confirm  
by means of another button that updates the array substituting the zero  
initials for the values settled down by each of the pressed buttons.  
Then the updated array continues containing even many zeros and therefore the minimum value obtained is 0.

I would like to know if some function or prototype is able to delete  
the elements of the array whose value is 0. I have tried to make it with  
the below function but the result that I obtain it’s not the one that I seek  
then it also delete the zeros in other elements of the array as 10, 101, 110, etc.  
Array.prototype.findAndRemove = function(toRemove) {  
var s = this.toString()+",";  
var t = s.split(toRemove+",");  
var u = t.join("");  
u = u.substr(0, u.length -1);  
var v = u.split(",");  
return v;  
};  
myArray = new Array(0, 0, 0, 0, 9, 10, 11, 12, 13, 14, 15, 16, 17);  
myArray = myArray.findAndRemove(0);
