<html>
<body>
<script type="text/javascript">
var categoryGroups = [
{
Id: 1, Categories:
[
{ Id: 1 },
{ Id: 2 },
]
},
{
Id: 2, Categories: [
{ Id: 100 },
{ Id: 200 },
]
}
]
var category, categoryGroup, found = false;
for (i = 0; i < categoryGroups.length ; i++) {
categoryGroup = categoryGroups[i];
for (j = 0; j < categoryGroup.Categories.length; j++) {
category = categoryGroup.Categories[j];
if (category.Id === categoryGroup.Id) {
found = true;
break;
window.document.write("category" );
}
}
if (found) break;
}
</script>
</body>
</html>
i have created nested array.from this nested array i want print object of an nested array.but unable to find object of an nested array. how to resolve this error?
{ Id: 1 }? and what do you do withcategory.Id === categoryGroup.Id?