I have array=
[{
"2022-12-06": [{
"student": "10",
"duration": "00:00:07",
"intervals": "1"
}]
},
{
"2022-09-08": [{
"student": "20",
"duration": "00:00:07",
"intervals": "1"
},
{
"student": "300",
"duration": "00:00:07",
"intervals": "1"
},
{
"student": "10",
"duration": "00:00:07",
"intervals": "1"
}
]
},
{
"date20221208": [{
"student": "10",
"duration": "00:00:07",
"intervals": "1"
},
{
"student": "10",
"duration": "00:00:07",
"intervals": "1"
},
{
"student": "10",
"duration": "00:00:07",
"intervals": "1"
},
{
"student": "10",
"duration": "00:00:07",
"intervals": "1"
},
{
"student": "10",
"duration": "00:00:07",
"intervals": "1"
}
]
}
]
I want find a date and return value date is exits or not
for eg.
i find 2022-12-06 if array have this value then true if not then false
I want find a date and return value date is exits or not
for eg.
i find 2022-12-06 if array have this value then true if not then false
2
Answers
you can use the Array.prototype.find() method to search for an object in an array. This method returns the first element in the array that satisfies the provided testing function.
For example, if you have an array of objects and you want to find an object with a specific date property, you could use the find() method like this:
First of all this question is not about react-native. This is about basic javascript.
You can use Array.Prototype.find() method.