So I have an object array that I need to check against a few variables I'm being sent. I am using underscore (plain javascript is fine too though) I have the object array looking like so -
var o = [{
module: "mod1",
customUrl: [{
"state": "name1",
"options": ["option1", "option2", "option3"]
}, {
"state": "name2",
"options": ["option1", "option2", "option3"]
}]
}, {
module: "mod2",
customUrl: [{
"state": "name1",
"options": ["option1", "option2", "option3"]
}, {
"state": "name2",
"options": ["option1", "option2", "option3"]
}]
}]
I have a function where I'm being passed three vars I would like to check if the last one exists inside of the first 2. Let me show you what I mean
test = function (module, state, option){
}
So what I am looking to do is, for example if I passed in
test(mod1,name1, option2);
I would like to check if there is a module with a key of "mod1", and then inside of that object there is an object inside of custom url with a state of "name1", and if that objects options array has the value "options2" inside of it. This is some more serious traversal, I could use some help. Thanks for reading!
test("mod1", "name1", "option2");