# Array.filter

**URL:** <https://forum.kirupa.com/t/array-filter/296418>\
**Category:** flash\
**Created:** [September 14, 2009, 9:34pm UTC](https://forum.kirupa.com/t/array-filter/296418 "2009-09-14T21:34:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![stickaforkinit](https://avatars.discourse-cdn.com/v4/letter/s/e0b2c6/32.png) [@stickaforkinit](https://forum.kirupa.com/u/stickaforkinit)\
**Post date:** [September 14, 2009, 9:34pm UTC](https://forum.kirupa.com/t/array-filter/296418/1 "2009-09-14T21:34:07Z")

</div>

I am trying to filter some content by alphabetical letter. ie(A=Animal, Arts,etc, B=Bug, Bit, Bat, etc).

I have it working for one letter at a time, which is ok I guess, but I rather have ranges like A-C, D-F,G-I etc.

Here is the code I am working with

```auto

package {
    import flash.display.Sprite;
    public class Array_filter extends Sprite {
        private var _letterRange:Array=new Array("A","B","C");
        private var _showsArray:Array=new Array("Mythbusters","Alphabet Goop","Brick and Brack","Dominio","Cats","Frogs and Pricess","Daniel Cook");
        public function Array_filter() {
            _showsArray.sort();
            var _showsArrayCopy:Array=_showsArray.map(arrayToUpperCase);
            var _showsFilteredArray:Array=_showsArrayCopy.filter(filterByLetter);
            trace(_showsFilteredArray);
        }
        private function arrayToUpperCase(element:String, index:int, array:Array):String {
            return (element.toUpperCase());
        }
        private function filterByLetter(element:String, index:int, array:Array):Boolean {
            for(var i=0;i<_letterRange.length;i++) {
                return element.charAt(0)==_letterRange*;
            }
        }
    }
}

```

The problem I am having is in the filterByLetter function as I can’t use a loop as it is giving me the following error:

1170:Function does not return a value

If I comment out the for loop and replace the index of the loop with a number instead of i it gives back the proper result.

Any suggestions?

Thanks in advance
