function recursion(time) {
                                //If the time is past the time of the current index
                                if (time >= data[index][0]) {
                                    //If index is the last one in the list just return the intensity of the current index
                                    if (index >= data.length - 1) {
                                        return data[index][1];
                                    }
                                    //If the time is between the current index and the next one, return the current index's intensity
                                    if (time < data[index + 1][0]) {
                                        return data[index][1];
                                    }
                                    //If the time is greater than the next index and you aren't at the end of the array recurse looking at the next index
                                    else {
                                        index++;
                                        return recursion(time);
                                    }
                                }
                                //if time is less than current index traverse backwards until this is not true
                                //or until you reach begining of array, the return the initial value
                                else {
                                    if (index <= 0) {
                                        return initial;
                                    }
                                    else {
                                        index--;
                                        return recursion(time);
                                    }
                                }
                            }
//A second recursive function so that it can call itself
A second recursive function so that it can call itself
A second recursive function so that it can call itself
function recursion(time) {
                                if (time >= data[index][0]) {
                                    if (index >= data.length - 1) {
                                        return data[index][1];
                                    }
                                    if (time < data[index + 1][0]) {
                                        return data[index][1];
                                    }
                                    else {
                                        index++;
                                        return recursion(time);
                                    }
                                }
                                else {
                                    if (index <= 0) {
                                        return initial;
                                    }
                                    else {
                                        index--;
                                        return recursion(time);
                                    }
                                }
                            }
function recursion ( time ) { if ( time >= data [ index ] [ 0 ] ) { if ( index >= data . length - 1 ) { return data [ index ] [ 1 ] ; } if ( time < data [ index + 1 ] [ 0 ] ) { return data [ index ] [ 1 ] ; } else { index ++ ; return recursion ( time ) ; } } else { if ( index <= 0 ) { return initial ; } else { index -- ; return recursion ( time ) ; } } }
A second recursive function so that it can call itself
A second recursive function so that it can call itself
//If the time is past the time of the current index //If index is the last one in the list just return the intensity of the current index //If the time is between the current index and the next one, return the current index's intensity //If the time is greater than the next index and you aren't at the end of the array recurse looking at the next index //if time is less than current index traverse backwards until this is not true //or until you reach begining of array, the return the initial value