I have an array of object that contain info this info are string numbers array
I'm trying to make a function that loop on all this info an print sector name and below the sector name in <li> tag print the licenseTitle each one of them in specific <li>
My problem is when i want to do that my loop print all the licenseTitle in database in the first sector name not like i want.
The output i want is for example
tourism
. tourism 1
. tourism 2
education
.education 1
.education 2
How Can i do that please?
const database = [{
sectorId: 1,
sectorName: "tourism",
sectorIcon: "icon-1.png",
sectorN: "tourism",
licenseTitle: ["tourism 1", "tourism 2"],
licenseNum: ["7960", "7961"]
},
{
sectorId: 2,
sectorName: "education",
sectorIcon: "icon-2.png",
sectorN: "education",
licenseTitle: ["education 1", "education 2"],
licenseNum: ["7950", "7951"]
}
]
//Print all sectors title with the license title and description
function AllSectors(){
for(let i = 0; i < database.length; i++){
document.querySelector('.content-right').innerHTML += `
<div class="box">
<div class="box-title">
<div class="title">
<input type="checkbox" value="${database[i].sectorN}" class="checktitle" name="sectorCheck">
${database[i].sectorName}
</div>
<div class="arrow">
<i class="fas fa-angle-down"></i>
</div>
</div>
<div class="box-details">
<ul class="details-list">`;
for(let j = 0; j < database[i].licenseTitle.length; j++){
document.querySelector('.details-list').innerHTML += `
<li><a href="#">${database[i].licenseTitle[j]}</a></li>
`;
}
`</ul>
</div>
</div>
`;
}
}
AllSectors();
<div class="content-right"></div>