search in string array javascript 1

search in string array javascript

function searchStringInArray (str, strArray) {
    for (var j=0; j

Here is what the above code is Doing:
1. It's creating a function called searchStringInArray.
2. It's taking two parameters: str and strArray.
3. It's looping through the strArray.
4. It's checking to see if the str parameter matches any of the items in the strArray.
5. If it does, it returns the index of the item in the array.
6. If it doesn't, it returns -1.

Similar Posts