If you're asking about better ways to tackle the problem, I would perhaps think about writing a function which can work with any number of dimensions in the array. In your example, the return value is the index of the top level array, but to make it generic, you would have to return the full "path" to the found element, and let the calling code decide what information it wants:
function multiFind(arr, val) { // please don't name an array "str"!
for (var i = 0, l = arr.length; i < l; ++i) {
if (arr[i] === val) {
return [i];
} else if (is_array(arr[i])) {
var ret = multiFind(arr[i], val);
if (ret !== false) {
ret.unshift(i);
return ret;
}
}
}
return false;
}
// this function by Doug Crockford
var is_array = function (value) {
return value &&
typeof value === 'object' &&
typeof value.length === 'number' &&
typeof value.splice === 'function' &&
!(value.propertyIsEnumerable('length'));
};
var inp = ["a","b",["c", ["d", "e", ["f", "g"], "h"]]];
multiFind(inp, "a"); // [0]
multiFind(inp, "b"); // [1]
multiFind(inp, "c"); // [2, 0]
multiFind(inp, "f"); // [2, 1, 2, 0]
multiFind(inp, "h"); // [2, 1, 3]
multiFind(inp, "x"); // false