Say I have a javascript objects that looks like this:
var events =
[
{
name: "Foo event",
submissions: [
{
id:"sub1",
name:"First submission"
},
{
id:"sub2",
name:"Second submission"
}
]
},
{
name: "Bar event",
submissions: [
{
id:"sub3",
name:"First submission in bar"
},
{
id:"sub4",
name:"Second submission in bar"
}
]
}
]
I want to be able to write a lamba function that, for instance returns the entire object
{
id:"sub4",
name:"Second submission in bar"
}
Given the id sub4. Something like var submission = events.magicLamba(...) I tried using Array.prototype.find, but that works if I have to select an object from an array of objects, in this case there's one more search above that.
Thanks for the help.
EDIT: As many of you have pointed out, events wasn't valid. It was indeed an array, I must have miswritten it while trying to write a simpler example of my original data.
eventsan array or object?