Is there a way that lets me loop through an object of arrays that contains objects?
I think it looks weird. Let me give you an example:
data {
monday = [
{from:"55:00", to:"12:00", txt: "hello"},
{from:"55:00", to:"12:00", txt: "study"},
{from:"55:00", to:"12:00", txt: "play"}
],
tuesday = [
{from:"7:00", to:"11:00", txt: "watch"},
{from:"09:00", to:"13:00", txt: "swim"},
]
}
Let's suppose that the user picks a day from a select option and that day will decide in which array of the data object the data that the user will input will be saved.
Is there a way that lets me prevent duplicated objects from being saved in the data object arrays?
I don't know why I feel it's not clear yet but here is another example: If the user picks the monday day, the inputs that he is going to input will be saved in the monday array as parameters of an object. I want to know if there is a way that lets me prevent a duplicated object in that array.
That's why I want to loop through them. I googled that issue and I found some solutions like the for..in but I don't think they fit my question. Thank you in advance.
mondaythen all you have to do is access that property either withdata.mondayordata['monday'], or if you have a variable that contains the string you can use that --data[yourVariable].