Question about function returning array data

Posted by Doug on Stack Overflow See other posts from Stack Overflow or by Doug
Published on 2010-04-12T02:10:34Z Indexed on 2010/04/12 2:13 UTC
Read the original article Hit count: 364

Filed under:
|
|
|
var grossBrackets = new Array( '300', '400', '500', '600', '700', '800', '900', '1000' );   
function bracketSort( itemToSort ) {
        for( index = 0 ; index < grossBrackets.length ; index++ ) {
            if ( itemToSort < grossBrackets[index] ) {
                bracketData[index]++;
            } else if ( itemToSort > grossBrackets[7] ) {
                grossBrackets[7]++;
            }
        }
        return bracketData;
    }

This is my current code, and I basically want to sort the data into their proper brackets. My source code is really long, but when I input these numbers into the function:

200.18
200.27
200.36
200.45
200.54

bracketData prints 5,5,5,5,5,5,5,5 or is there a better way to do this?

Brackets: <300, <400, <500, <600, <700, <800, <900, <1000, greater than 1000

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about function