I’m looking to set a variable based on which array a string exists in.
For example:
var primary = ["red", blue", "yellow"];
var secondary = ["orange", "purple", "green"];
Then check for “purple” and return that it is in the “secondary” array and assign it to a variable to use later.
jQuery or Javascript is fine.
Not sure what you wanted to assign to a variable, so I just used alerts to illustrate the result
Example: http://jsfiddle.net/S9WL6/
Then you can make it into a reusable function:
EDIT: Or make it into a function that can accept a variable number of Arrays.
Example: http://jsfiddle.net/5pZUQ/