Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function dualHeadedSearch(array, search){
- var arrayLength = array.length;
- var output = new array();
- for (var i = arrayLength - 1; i >= 0; i--) {
- //starts from end back
- if (array[i] == search && dualHeadedSearch(output, i) == false) {
- output.push(i);
- }
- //starts from start forward
- if(array[arrayLength - i] == search && dualHeadedSearch(output, i) == false){
- output.push(arrayLength - i);
- }
- }
- if (output.length > 0) {
- return output;
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement