im having a problem with some code that i have. I have the following object (bookingDetails) that has a 'type' property that is an array, which stores objects, which in turn has another array of objects. for example:
bookingDetails (object)
- type(array)
- id
- share (array)
Number (object)
First off is there a better way to do this? (i need to be able to store numerous 'Numbers' against the share per type)
Secondly if someone clicks a big old 'X' then i need to delete the number from the correct share and, if the share is empty delete the entire type object that the share belonged to.
at the moment i was trying to do this with the following:
for(var d in bookingDetails[data[6]]){
var it = bookingDetails[data[6]][d];
if(it.ID === data[0]){
for(var s in it.Sharing){
var pa = it.Sharing[s];
for(var p in pa){
var pax = pa[p];
for(var pd in paxData){
if(pax.PaxNo === paxData[pd]){
//what to do here??
}
}
}
}
}
}
i had a look at splice to remove the objects from the share array but this would then change the array indexes which i a problem for the above loops... it all just seems messy.
Any help would be vastly appreciated as i have been trying to do this for a while now..
If this is not the best method of doing this I would love to know of a better way :)
Thanks